Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show menu items when click on any item

Extjs Menu hide when clicked on any item. I want to show menu even when someone click on menu Item.

Fiddle: 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'
    }]
}
});
like image 618
Ajay Thakur Avatar asked Jan 01 '26 15:01

Ajay Thakur


1 Answers

You can try this - add enableToggle: true to the button, and add a listener on beforehide of the menu like:

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

like image 52
CD.. Avatar answered Jan 03 '26 10:01

CD..



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!