我定義了一個包含多個選項卡的tabpanel,其中一個選項卡中有一個面板,其中包含網格和其他內容。我定義了一個控制器來從網格中獲取事件。雖然我可以從面板中獲取事件,但無法從網格中獲取事件。ExtJS 4不能監聽組件內部的事件
這裏的視在這裏:
Ext.define('test.MyViewport', {
extend: 'Ext.container.Viewport',
layout: 'fit',
items: {
xtype: 'tabpanel',
items: [{
title: 'Tab 1',
html: 'something'
},{
title: 'Tab 2',
xtype: 'mypanel'
},{
title: 'Tab 3',
html: 'something else 2'
}]
}
這裏的面板:
Ext.define('test.MyPanel', {
extend: 'Ext.container.Container',
alias: 'widget.mypanel',
layout: {
type: 'hbox',
border: 1
},
items: [{
xtype: 'mygrid',
width: 300
},{
xtype: 'component',
html: 'Hello There'
}]
});
而這裏的控制器:
Ext.define('test.MyController', {
extend: 'Ext.app.Controller',
init: function() {
this.control({
'mypanel': { show: function(){console.log("Show Panel");} },
'mygrid': { show: function(){console.log("Show Grid");} }
});
}
});
完整的代碼可以在此fiddle進行測試。
我嘗試了許多不同的選擇:
mypanel mygrid
#my-grid-id (setting itemId on the grid item in the panel)
mypanel #my-grid-id
...
沒有成功。我已經花了兩天的時間對此沒有線索瞭解如何解決。我應該爲該特定視圖啓動一個不同的控制器嗎?如果是的話我應該把它放在哪裏?
非常感謝
+1我喜歡在小提琴的工作示例! – rixo