admin管理员组文章数量:1312985
I'm using ExtJs4 and I'm trying to extend the Ext.form.field.ComboBox
like below:
Ext.define('GenericCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.genericbo',
//the constructor
constructor: function(config) {
var store = new Ext.data.JsonStore({
fields: ['Key', 'Value'],
data : configbodata || []
});//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
The data for the store i.e. configbodata
is returned in JSON format like below:
"bodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"},
{"Key":"!$","Value":"Miss"}
]
However I get an error on line 61312
of ext-all-debug.
(inside the renderActiveError method).
Error: Uncaught TypeError: Cannot read property 'dom' of null
Line 61312 :
me.errorEl.dom.innerHTML = activeError;
Am I missing something obvious here?
EDIT: Adding some code where I instantiate it:
I actually instantiate the bobox dynamically i.e. The server returns some extjs code dynamically in JSON format like below:
{
"anchor":"50%",
"autoScroll":false,
"border":false,
"bodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"}
],
"fieldLabel":"Title",
"name":"3820",
"value":"!)",
"xtype":"genericbo"
}
However When i try to hardcode it i get the same error. Hardcoded example:
xtype: 'form',
title: 'A Form',
items:[{
xtype: 'genericbo',
fieldLabel: 'Test',
bodata: [{Key: 'one', Value: 'two'}]
}]
I'm using ExtJs4 and I'm trying to extend the Ext.form.field.ComboBox
like below:
Ext.define('GenericCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.genericbo',
//the constructor
constructor: function(config) {
var store = new Ext.data.JsonStore({
fields: ['Key', 'Value'],
data : config.bodata || []
});//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
The data for the store i.e. config.bodata
is returned in JSON format like below:
"bodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"},
{"Key":"!$","Value":"Miss"}
]
However I get an error on line 61312
of ext-all-debug.
(inside the renderActiveError method).
Error: Uncaught TypeError: Cannot read property 'dom' of null
Line 61312 :
me.errorEl.dom.innerHTML = activeError;
Am I missing something obvious here?
EDIT: Adding some code where I instantiate it:
I actually instantiate the bobox dynamically i.e. The server returns some extjs code dynamically in JSON format like below:
{
"anchor":"50%",
"autoScroll":false,
"border":false,
"bodata":[
{"Key":"","Value":"<None>"},
{"Key":"!#","Value":"Dr"}
],
"fieldLabel":"Title",
"name":"3820",
"value":"!)",
"xtype":"genericbo"
}
However When i try to hardcode it i get the same error. Hardcoded example:
xtype: 'form',
title: 'A Form',
items:[{
xtype: 'genericbo',
fieldLabel: 'Test',
bodata: [{Key: 'one', Value: 'two'}]
}]
Share
Improve this question
edited May 30, 2011 at 16:31
shane87
asked May 30, 2011 at 16:00
shane87shane87
3,12013 gold badges52 silver badges65 bronze badges
2
- can you show the code where you're instantiating it? – JamesHalsall Commented May 30, 2011 at 16:16
- @Jaitsu: I have added some more code to my original question explaining how I instantiate it.. – shane87 Commented May 30, 2011 at 16:32
2 Answers
Reset to default 3I was calling
this.callParent([this]); //Which is wrong and caused my error.
The correct way is to call
this.callParent([arguments]);
Try this... move everything in your constructor
to the initComponent
method. Then in your constructor
you need to call the parent's constructor
...
constructor : function(config) {
GenericCombo.superclass.constructor.apply(this,new Array(config);
}
I would also consider namespacing your ponent... something like Ext.ux.GenericCombo
would be better suited.
版权声明:本文标题:javascript - Error trying to extend ExtJs ComboBox - "Cannot read property 'dom' of null"? - S 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741888968a2403187.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论