EasyUI Forum
April 28, 2024, 03:43:59 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: hideItem/showItem in menu not working properly  (Read 876 times)
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« 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]); 
                                                            }
                                                       
                                                    }
                                                    });

Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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);
    }
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!