2010-08-19 27 views

回答

18

在按鈕菜單中使用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(''); 
}); 
+0

也不會解釋它更好。 – Drasill 2010-08-20 07:21:17

+0

絕對精彩 - 非常感謝您的迅速和明確的答覆! :) – SW4 2010-08-20 09:02:24

+0

ExtJS 5.0.1 API鏈接:http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.util.MixedCollection – SW4 2015-01-12 08:56:17