In ExtJS, How Can You Loop Through Menu Items?

我的梦境 提交于 2019-12-22 06:49:25

问题


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


回答1:


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('');
});


来源:https://stackoverflow.com/questions/3523733/in-extjs-how-can-you-loop-through-menu-items

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!