EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: poeziafree on January 19, 2023, 03:13:57 AM



Title: hideItem/showItem in menu not working properly
Post by: poeziafree on January 19, 2023, 03:13:57 AM
Hello,

hideItem/showItem in menu doesn't work properly.

In case there are two identical menus, where item ids aren't unique, hideItem/showItem only works for one menu.

I think, the problem is with this code:

$(_482).show();

$(_482).hide();

it should find the item id within the menu ( e.g. menu.find(_482).hide() )

Currently, it searched the item id on the whole page, instead within the menu.

Code:

Code:
var m = $(this).datagrid('getPanel').find('#actions-btn').menubutton('options').menu;  // get the menu object
                                                 
                                                    var item = m.menu('findItem', function(item){
                                                    if (item.id == 'resend'){
                                                       
                                                        if (data.row.status == "Scheduled")
                                                            {
                                                                 m.menu('hideItem', $('#'+item.id)[0]); 
                                                            }
                                                            else
                                                            {
                                                                m.menu('showItem', $('#'+item.id)[0]); 
                                                            }
                                                       
                                                    } else {
                                                       
                                                        if (data.row.status == "Scheduled")
                                                            {
                                                                 m.menu('showItem', $('#'+item.id)[0]); 
                                                            }
                                                            else
                                                            {
                                                                m.menu('hideItem', $('#'+item.id)[0]); 
                                                            }
                                                       
                                                    }
                                                    });



Title: Re: hideItem/showItem in menu not working properly
Post by: jarry on January 19, 2023, 08:36:23 PM
The 'findItem' method allows you to find one menu item that matches specified conditions, and then do the action according to your logic. Please don't search an item using the same 'id' property that defined for multiple components on the page. If you want to navigate all the items, please call the 'navItems' method instead. Make sure to update to the latest version.

Code:
m.menu('navItems', function(item){
    if (...){
        m.menu('hideItem', item.target);
    } else {
        m.menu('showItem', item.target);
    }
})