PDA

View Full Version : Ext.data.Store : Add a new configuration to proxy Store



faycel
17 Jun 2014, 10:49 PM
Hi ,
I tried to create a new instance of a class 'Toto.data.Store' which have a proxy , my problem is to add a new configuration to proxy ... that's my code :


var newStore = Ext.create('Toto.data.Store',{
storeId : 'toto',
autoLoad : true ,
proxy : Ext.applyIf(this.proxy , { extraParams : { titi : 20} ,
pageParam: undefined, startParam: undefined,
limitParam: undefined})
});

but I don't see any modification in my store.

Thanks for help.

mitchellsimoens
26 Jun 2014, 6:36 AM
When you use this.proxy, the scope is the window not magically the store. For this, I would do something in the constructor to give the store a custom config:


Ext.define('Toto.data.Store', {
extend : 'Ext.data.Store',

extraParams : null,

proxy : {
type : 'ajax',
url : 'foo.json'
},

constructor : function(config) {
var proxy = config && config.proxy ? config.proxy : this.proxy,
extraParams = proxy.extraParams;

proxy.extraParams = Ext.apply(extraParams, this.extraParams);

config.proxy = proxy;

this.callParent([config]);
}
});

Do note, this was just typing off the top of my head.