PDA

View Full Version : Inherited class does not keep in-defined properties. They're set to null



ValiBOSS
20 Aug 2009, 1:28 PM
Let us have the following code:


Ext.ux.CoolCombo = Ext.extend(Ext.form.ComboBox, {
initComponent: function(){
var _this=this;

Ext.apply(this, {
typeAhead: true,
triggerAction: 'all',
anyMatch: true,
allowBlank: false,
lazyRender:false,
displayField: 'name',
valueField: 'id',
lazyInit: true,
mode: 'local'
});

Ext.ux.CoolCombo.superclass.initComponent.apply(this, arguments);

this.on('expand',function(combo) {
if (this.store.ismodified === true) {
this.getStore().load({
callback: function() {
_this.store.ismodified = false;
}
});
}
},this);
}
});

The problem is:

if I declare a variable like


var myCombo = new Ext.ux.CoolCombo({
store : ...
});
(that is, without specifing here the displayField and valueField),
myCombo will NOT have the default displayField and valueField(name and id) mentioned in the class declaration. Instead, they appear as undefined.

Why?