在回到ExtJS4文檔並在他們的示例行中複製行以嘗試排除我可能出錯的位置時,我很難過。嗅探initComponent處於不幸的操作順序問題。ExtJS4:創建在initComponent中的存儲在表單面板中未定義
正在定義的商店是1)沒有填充字段,2)在試圖從字段監聽器調用它之後被認爲是未定義的。
我定義一個存儲這樣在initComponent,
Ext.define('X.view.NewLogWindow', {
extend: 'Ext.window.Window',
xtype:'newlogwindow',
itemId: 'newLogWindow',
width: 300,
height: 140,
modal: true,
title: 'Create Log',
layout: 'fit',
initComponent: function() {
this.monthStore = Ext.create('Ext.data.Store', {
fields : [
{name : 'id', type : 'int'}, {name : 'month', type : 'string'}
],
autoLoad: true,
data : [
{"id" : 0, "month" : "January"},
{"id" : 1, "month" : "February"},
{"id" : 2, "month" : "March"},
{"id" : 3, "month" : "April"},
{"id" : 4, "month" : "May"},
{"id" : 5, "month" : "June"},
{"id" : 6, "month" : "July"},
{"id" : 7, "month" : "August"},
{"id" : 8, "month" : "September"},
{"id" : 9, "month" : "October"},
{"id" : 10, "month" : "November"},
{"id" : 11, "month" : "December"}
]
});
var x = 'fixme';
console.log(this.monthStore);
console.log(x);
this.callParent();
}
然後,我分配存儲到該組合框的形式面板這樣:
items: [
{
xtype: 'form',
margin: 10,
border: false,
defaults: {allowBlank: false},
items: [
{
xtype: 'combobox',
fieldLabel: 'Log Month',
store: this.monthStore,
queryMode : 'local',
displayField: 'month',
valueField: 'id',
listeners: {blur: function(field)
{
console.log(this.monthStore);
console.log(this.x);
}
}
}
]
}
]
下面是從輸出我的控制檯日誌記錄:
constructor NewLogWindow.js:40
fixme NewLogWindow.js:41
undefined NewLogWindow.js:74
undefined NewLogWindow.js:75
在此先感謝。
缺點是「將其添加到表單面板」。怎麼樣?窗口與這種形式有什麼關係? –