如何在 Flex 中隐藏/显示特定的上下文菜单项?
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中,我完成了上下文菜单,如果我右键单击然后显示上下文菜单项,但我想隐藏列表中的特定上下文菜单项,是否可以隐藏并显示上下文菜单中的特定项目? 键值
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" />
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);
In flex i done contex menu , if i rigt click then show context menu item but i want to hidden particular context menu item in list , is it possiable hidden and show particular items in context menu ? please refer me , i tried key value based
if(Application.application.contact_key==1)
{
contextMenu.customItems.push(deletecontact);
}
else
{
contextMenu.customItems.push(removeContactList);
}
contextMenu.customItems.push(TimeList);
return contextMenu;
Within itemRenderer
All coding on contactListItemRenderer.as and call to datagrid like
<mx:DataGridColumn itemRenderer="com.view.Contact.ContactListItemRenderer"
dataField="fullName" headerText="Full Name" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 contextMenu.customItem 访问自定义菜单项并隐藏/显示任何特定项目。对于内置菜单项,您可以访问 contextMenu.builtInItems (请参阅下面的代码):
You can access the custom menu items by contextMenu.customItem and hide/show any particular item. For the build in menu items you can access contextMenu.builtInItems (see the code below):