2010-11-05 31 views
0

我可以管理從其他tbar禁用/啓用extjs tbar?管理從其他tbar禁用/啓用extjs tbar

感謝您的回答。我的解決方案,這樣的事情:

tbar:[{ id:'tambahid', 
disabled:true, 
     }, 
     { text: 'Toggle' + (local ? 'Off' : 'On'), 
enableToggle: true, 
toggleHandler: 
function(){ 
var hidd = Ext.getCmp('tambahid'); 
    if (this.pressed){Ext.Msg.alert(' ','Tambah Data Off'); 
     hidd.enable(); 
      }    

其他{Ext.Msg.alert(」」, 'Tambah方面的數據'); hidd.disable(); }}

但我敢肯定,更高效,更清晰的代碼在那裏。

回答

2
// ... 
tbar: new Ext.Toolbar({ 
    id: 'mytb', 
    items: [/* your tbar items */] 
}) 
// ... 

Ext.getCmp('mytb').disable(); 
+0

Ext.getCmp是你最好的frand – 2010-11-11 15:45:07

+0

一些熱烈的討論:Ext.getCmp在這裏:http://www.sencha.com/forum/showthread.php ?103569-Ext.getCmp和開發人員,使用,它作爲一種-柺杖 – DanB 2010-11-12 09:30:03

0

你可以使用一個消息總線傳遞解耦組件之間的消息,但是這可能是矯枉過正這種情況下..假設兩者的工具欄屬於同一個父組件,則父母會承擔責任,啓用/禁用其他工具欄基於第一個工具欄上的某些操作。在這裏看到這個例子的想法從哪裏開始:http://examples.extjs.eu/?ex=compcomm

相關問題