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 i done contex菜单中,如果我点击然后显示上下文菜单项但我想隐藏列表中的特定上下文菜单项,是否可以隐藏并在上下文菜单中显示特定项目?请参考我,我尝试了基于键值的
if(Application.application.contact_key==1)
{
contextMenu.customItems.push(deletecontact);
}
else
{
contextMenu.customItems.push(removeContactList);
}
contextMenu.customItems.push(TimeList);
return contextMenu;
在itemRenderer中
所有在contactListItemRenderer.as上编码并调用datagrid,如
<mx:DataGridColumn itemRenderer="com.view.Contact.ContactListItemRenderer"
dataField="fullName" headerText="Full Name" />
答案 0 :(得分:0)
您可以通过contextMenu.customItem访问自定义菜单项并隐藏/显示任何特定项目。对于构建菜单项,您可以访问contextMenu.builtInItems(请参阅下面的代码):
contextMenuCustom.builtInItems.zoom = false;
contextMenuCustom.builtInItems.save = true;