单击任何项​​目时显示菜单项

时间:2017-01-02 11:26:13

标签: javascript jquery html css extjs

单击任何项​​目时,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'
    }]
}
});

1 个答案:

答案 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'
        }]
    }
});

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