在回到 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
提前致谢。