PDA

View Full Version : Appending params of descendants



1099511627776
28 Apr 2012, 11:42 AM
Hello world,
Heve is what i want to do:
I have a base class (Ext.data.Store for example) with some custom parameters:


extraParams: {
plugin:'documents'
}

I want to write a descendant of this class with this params:


extraParams: {
action:'update'
}

and as a Result I would like to have in methods (for example in initComponent ):


extraParams:{
plugin:'documents';
action:'update'
}


Is there any way to do this ? or it would be more easy just define all params in descendant?

vietits
28 Apr 2012, 3:52 PM
Try this


Ext.define('A', {
extend: 'Ext.data.Store',
....
constructor: function(config){
var me = this;
config = Ext.apply({}, config, {
proxy: {
type: 'ajax'
}
});
config.proxy.extraParams = Ext.apply({}, config.proxy.extraParams, {
plugin: 'documents'
});
me.callParent([config]);
}
});


Ext.define('B', {
extend: 'A',
constructor: function(config){
var me = this;
config = Ext.apply({}, config, {
proxy: {
type: 'ajax'
}
});
config.proxy.extraParams = Ext.apply({}, config.proxy.extraParams, {
action: 'update'
});
me.callParent([config]);
}
});