我使用ExtJs4我试图延长Ext.form.field.ComboBox
象下面这样:尝试扩展ExtJs ComboBox时出错 - “无法读取'null'的属性'dom'?
Ext.define('GenericCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.genericcombo',
//the constructor
constructor: function(config) {
var store = new Ext.data.JsonStore({
fields: ['Key', 'Value'],
data : config.combodata || []
});//new Ext.data.Store
Ext.apply(this, config, {
store: store,
displayField: 'Value',
valueField: 'Key',
queryMode: 'local',
emptyText:'Select a value...'
});
this.callParent([this]);
}//end constructor
});//end Ext.define
的数据为存储即config.combodata
返回JSON格式如下图所示:
"combodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"},
{"Key":"!$","Value":"Miss"}
]
不过我得到ext-all-debug的行61312
的错误。
(在renderActiveError方法中)。
错误:Uncaught TypeError: Cannot read property 'dom' of null
线61312:
me.errorEl.dom.innerHTML = activeError;
我失去的东西在这里很明显?
编辑:添加一些代码,我实例化它:
其实我实例化组合框动态地即服务器动态地返回一些ExtJS的代码以JSON格式如下图所示:
{
"anchor":"50%",
"autoScroll":false,
"border":false,
"combodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"}
],
"fieldLabel":"Title",
"name":"3820",
"value":"!)",
"xtype":"genericcombo"
}
但是当我尝试硬编码它,我得到相同的错误。硬编码的例子:
xtype: 'form',
title: 'A Form',
items:[{
xtype: 'genericcombo',
fieldLabel: 'Test',
combodata: [{Key: 'one', Value: 'two'}]
}]
你能证明你在哪里实例化它的代码? – JamesHalsall 2011-05-30 16:16:18
@Jaitsu:我已经添加了一些更多的代码来解释我如何实例化它。 – shane87 2011-05-30 16:32:46