views:

70

answers:

1

All, Using Ext JS, if you have a panel with a toolbar that has a menu with several items in it, how can you loop through all items within that menu to, say, remove the respective items icons (i.e. change setIconClass to '')?

Many thanks in advance for the response!

+4  A: 

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('');
});
owlness
Wouldn't have explained it better.
Drasill
Absolutely fantastic- many thanks indeed for the prompt and clear answer! :)
Ergo Summary