2017-01-02 61 views
3

Extjs菜单隐藏点击任何项目。即使有人点击菜单项目,我也想显示菜单。点击任何项目时显示菜单项

小提琴:https://fiddle.sencha.com/#view/editor&fiddle/1nfo

Ext.create('Ext.button.Button', { 
text:'menu open', 
id: 'todostatusFilter', 
renderTo:Ext.getBody(), 
menu: { 
    xtype: 'menu', 
    id: 'todostatusFilterMenu', 
    items: [{ 
     text: 'All', 
     action: 'All', 
     checked: true, 
     group: 'todoSortByStatus' 
    },{ 
     text: 'incomplete', 
     action: 'Incomplete', 
     checked: false, 
     group: 'todoSortByStatus' 
    }, { 
     text: 'Complete', 
     action: 'Complete', 
     checked: false, 
     group: 'todoSortByStatus' 
    }] 
} 
}); 

回答

3

你可以试试这个 - 添加enableToggle: true到该按钮,并在诸如菜单beforehide添加一个侦听器:

button = Ext.create('Ext.button.Button', { 
    text: 'menu open', 
    id: 'todostatusFilter', 
    renderTo: Ext.getBody(), 
    enableToggle: true, 
    menu: { 
     xtype: 'menu', 
     id: 'todostatusFilterMenu', 
     listeners: { 
      beforehide: function() { 
       return !button.pressed; 
      } 
     }, 
     items: [{ 
      text: 'All', 
      action: 'All', 
      checked: true, 
      group: 'todoSortByStatus' 
     }, { 
      text: 'incomplete', 
      action: 'Incomplete', 
      checked: false, 
      group: 'todoSortByStatus' 
     }, { 
      text: 'Complete', 
      action: 'Complete', 
      checked: false, 
      group: 'todoSortByStatus' 
     }] 
    } 
}); 

https://fiddle.sencha.com/#view/editor&fiddle/1nfp

+0

感谢。在隐藏函数之前,有没有办法检查哪个项目被点击? –

+0

@AjayThakur你可以找到检查的项目,试试这个:https://fiddle.sencha.com/#view/editor&fiddle/1nfr –

相关问题