我使用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