5
如何遍歷ExtJS工具欄菜單中的所有項目,例如更改它們的圖標?在ExtJS中,如何循環顯示菜單項?
如何遍歷ExtJS工具欄菜單中的所有項目,例如更改它們的圖標?在ExtJS中,如何循環顯示菜單項?
在按鈕菜單中使用MixedCollection實例的'each'方法。
假設一個定義,如:
var pnl = new Ext.Panel({
tbar: [
{
itemId: 'a_btn',
text: 'A menu button',
menu: {items: [
{
text: 'Item 1'
},
{
text: 'Item 2'
}
]}
}
]
});
你可以再後來做:
var btn = pnl.getTopToolbar().get('a_btn');
btn.menu.items.each(function(item) {
item.setIconClass('');
});
也不會解釋它更好。 – Drasill 2010-08-20 07:21:17
絕對精彩 - 非常感謝您的迅速和明確的答覆! :) – SW4 2010-08-20 09:02:24
ExtJS 5.0.1 API鏈接:http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.util.MixedCollection – SW4 2015-01-12 08:56:17