如何在 Flex 中隐藏/显示特定的上下文菜单项?

发布于 2024-08-30 02:40:01 字数 1930 浏览 2 评论 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中,我完成了上下文菜单,如果我右键单击然后显示上下文菜单项,但我想隐藏列表中的特定上下文菜单项,是否可以隐藏并显示上下文菜单中的特定项目? 键值

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心在旅行 2024-09-06 02:40:01

您可以通过 contextMenu.customItem 访问自定义菜单项并隐藏/显示任何特定项目。对于内置菜单项,您可以访问 contextMenu.builtInItems (请参阅下面的代码):

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

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):

        contextMenuCustom.builtInItems.zoom = false;
        contextMenuCustom.builtInItems.save = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文