PDA

View Full Version : Load stores



Jad
29 Jul 2016, 5:32 AM
Hy every one

I've defined one model like that


Ext.define('Model', {
extend: 'Ext.data.Model',


fields: [
{
name: 'id',
type: 'int'
},{
...
}
],


proxy: {
type: 'ajax',
timeout: 600000,
api: {
create: '...',
read: '...',
update: '...',
destroy: '...'
},
reader: {
type: 'json',
root: 'root',
record: 'record'
}
}
});

and one store like that


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


requires: [
'Model'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'Model',
remoteFilter: true
}, cfg)]);
}
});


I want to use the store on 2 differents grids

So I've created loaded and binded that 2 stores



var store_1= Ext.create('Store');
var store_2= Ext.create('Store');

store_1.getProxy().extraParams = store_1_extra_params;
store_1.load(function () {
grid_1.reconfigure(store_1);
grid_1_pagingtoolbar.bindStore(store_1);
grid_1_pagingtoolbar.doRefresh();
});

store_2.getProxy().extraParams = store_2_extra_params;
store_2.load(function () {
grid_2.reconfigure(store_2);
grid_2_pagingtoolbar.bindStore(store_2);
grid_2_pagingtoolbar.doRefresh();
});


My probleme is if I change the page on the first grid the store_2 use the store_1 extraParams instead of his.

What I've done wrong

Pleas help :(

Jad
8 Aug 2016, 11:08 PM
I have found the solution (https://www.sencha.com/forum/showthread.php?223723-setting-proxy-extraParams-set-it-for-all-new-instances)

The proxy had to be cloned



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


requires: [
'Model'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'Model',
remoteFilter: true
}, cfg)]);
me.setProxy(Ext.Object.merge({}, me.getProxy()));
}
});