私はextJSを初めて使用しますが、正しい戦略がわからない場合もあるので、必要に応じてより良い解決策を教えてください。
私が試していること:extJSグリッドがあります。ダブルクリックすると、複数のタブが含まれるExtJSウィンドウコンテナ(詳細設定用)が表示されます。ウィンドウには、クリックした要素のIDを設定する機能があります。ウィンドウ内のすべてのタブにもこのIDが必要です。そこで、ウィンドウコンテナでIDが変更されたときに、変更されたIDについてイベントを介してすべてのタブコンテナに通知したいと思います。
私の問題は、ウィンドウが最初に開かれるまでレンダリングされないため、タブからウィンドウにアクセスしてリスナーを追加できないことです。
私のソースコードを見ると、私の問題をよりよく理解できるかもしれません。
ウィンドウ (グリッド要素をダブルクリックすると、setCustomerId()とshow()が呼び出されます)
Ext.define('myApp.path.view.Edit', {
extend: 'Ext.window.Window',
alias: 'widget.myEdit',
title: 'Edit',
height: 500,
width: 1000,
layout: 'fit',
closeAction: 'hide',
/**
* Initialize my custom event
*/
initComponent: function() {
this.addEvents('customerChanged');
this.callParent();
},
/**
* Sets the current customerId and fires a customerChanged event
* @param {Number} customerId
*/
setCustomerId: function(customerId) {
this.customerId = customerId;
this.fireEvent('customerChanged', this.customerId);
},
/**
* create a container for the editor tabs
*/
items: [{
xtype: 'tabpanel',
items: [
{
xtype: 'myTab'
}
]
}]
})
サンプルタブ
Ext.define('myApp.path.view.myTab', {
extend: 'Ext.container.Container',
alias: 'widget.myTab',
title: 'Customer',
layout: 'fit',
/**
* Listen to my custom event
* PROBLEM: works, but only after the window has been displayed one time
*/
afterRender: function() {
this.findParentByType('window').addListener("customerChanged", this.onCustomerChanged)
this.callParent();
},
/**
* Listen to my custom event
* PROBLEM: doesn't work, findParentByType('window') is undefined
*/
initComponent: function() {
this.findParentByType('window').addListener("customerChanged", this.onCustomerChanged)
this.callParent();
},
onCustomerChanged: functio() {}
})
私の意図を理解していただければ幸いです。ありがとうございました!