2010-04-26 89 views
0
var contextMenu:ContextMenu = new ContextMenu(); 

     contextMenu.hideBuiltInItems(); 

     var contactList : ContextMenuItem = new ContextMenuItem("Add to Existing List"); 
     contactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doStaticListCommand); 

     var newContactList : ContextMenuItem = new ContextMenuItem("Add a New List"); 
     newContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doNewStaticListCommand); 

     var removeContactList : ContextMenuItem = new ContextMenuItem("Remove contact from List"); 
     removeContactList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doRemoveListCommand); 

     var deletecontact:ContextMenuItem = new ContextMenuItem("Delete contact"); 
     deletecontact.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, dodeleteconactCommand); 

     var TimeList : ContextMenuItem = new ContextMenuItem("Add Time Spent"); 
     TimeList.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, doTimeListCommand); 

     contextMenu.customItems.push(contactList);  

     contextMenu.customItems.push(newContactList);   

     contextMenu.customItems.push(deletecontact); 

     contextMenu.customItems.push(removeContactList); 

在flex中我完成了高級菜單,如果我點擊然後顯示上下文菜單項但我想隱藏特定的上下文菜單項在列表中,它是否可隱藏並在上下文菜單中顯示特定項目?請參考我,我想基於如何在flex中隱藏/顯示特定的上下文菜單項?

if(Application.application.contact_key==1) 
{ 
     contextMenu.customItems.push(deletecontact); 
    } 
     else 
    { 

      contextMenu.customItems.push(removeContactList); 
    } 

     contextMenu.customItems.push(TimeList); 

     return contextMenu; 

鍵值在itemRenderer的

上contactListItemRenderer.as所有編碼和調用數據網格狀

<mx:DataGridColumn itemRenderer="com.view.Contact.ContactListItemRenderer" 
         dataField="fullName" headerText="Full Name" /> 

回答

0

您可以通過文本菜單訪問自定義菜單項。 customItem並隱藏/顯示任何特定的項目。對於菜單項的構建,您可以訪問contextMenu.builtInItems(見下面的代碼):

 contextMenuCustom.builtInItems.zoom = false; 
     contextMenuCustom.builtInItems.save = true; 
+0

它不工作茱萸Creanga – 2010-04-27 07:32:05

+0

感謝您迴應我Mr.Cornel Creanga – 2010-04-27 07:41:39