Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ExtJS, How Can You Loop Through Menu Items?

How can you loop through all the items in an ExtJS toolbar menu, for example to change their icons?

like image 924
SW4 Avatar asked Aug 19 '10 16:08

SW4


1 Answers

Use the 'each' method of the MixedCollection instance in the button's menu.

Assuming a definition like:

var pnl = new Ext.Panel({
    tbar: [
        {
            itemId: 'a_btn',
            text: 'A menu button',
            menu: {items: [
                {
                    text: 'Item 1'
                },
                {
                    text: 'Item 2'
                }
            ]}
        }
    ]
});

You can then later do:

var btn = pnl.getTopToolbar().get('a_btn');

btn.menu.items.each(function( item ) {
    item.setIconClass('');
});
like image 90
owlness Avatar answered Nov 15 '22 00:11

owlness