PDA

View Full Version : ExtJs config



pinidbest
10 May 2012, 2:17 AM
Hi all,
If my base class has a config propery with some properties with default values
And i want my derived class to override these values not in its creation by in ints defintion
How to i do that?

Do I write the config again in the derived class or use the derived contructor?

friend
10 May 2012, 4:32 AM
Here's the proper way to construct your class such that object instances can properly override default values:



Ext.define('MyCustomClass', {
extends: 'Ext.Component',

config: {
someProperty: 'defaultValue'
},

constructor: function(config) {
this.initConfig(config);
}
});

var instance1 = Ext.create('MyCustomClass');
console.log('instance1.getSomeProperty() = ' + instance1.getSomeProperty());

var instance2 = Ext.create('MyCustomClass', {
someProperty: 'overriddenValue'
});
console.log('instance2.getSomeProperty() = ' + instance2.getSomeProperty());

pinidbest
10 May 2012, 4:37 AM
Hi, thanks for the reply
This is not what I asked.

I need that my base class will contain some config properies
But the my bclasses may need to change these values during their definition in the ext.define