2010-04-26 86 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