单击任何项目时,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'
}]
}
});
答案 0 :(得分: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'
}]
}
});