marxan
6 Jul 2012, 12:59 AM
Hello,
I have this issue for 2 days now and nothing seems to work.
What I want to do is very simple. I have 2 stores. I use the first one with a proxy to get data from DB.
Then I want to copy the datas I have retrieved to another store that I will link to a grid to display the data. I want to do this to avoid calling the database to much times.
Unfortunately I can't achieved that.
My first store
Ext.define('TAB.store.MetrSeriesStore', {
extend: 'Ext.data.Store',
requires: 'TAB.model.SerieGridModel',
model: 'TAB.model.SerieGridModel',
storeId: 'metrSeries',
groupField: 'CODEFC',
buffered: true,
pageSize: 100,
proxy: {
type: 'ajax',
url: 'app/data/loader.cfc?method=getMetrSeries&returnformat=json',
reader: {
type: 'json',
root: 'DATA'
}
}
});
The second store (should I also use a proxy to copy data in this one? )
Ext.define('TAB.store.MetrSeriesDisplayedStore', {
extend: 'Ext.data.Store',
requires: 'TAB.model.SerieGridModel',
model: 'TAB.model.SerieGridModel',
storeId: 'metrSeriestoDisplay',
proxy: {
type: 'rest',
reader: {
type: 'json',
root: 'data'
}
}
});
My controller that tries to copy data's
var store = Ext.getStore('MetrSeriesStore');
var storeForGrid = Ext.getStore('MetrSeriesDisplayedStore');
store.proxy.extraParams = {
codes : Global.codeListToLoad
}
// I load data in my first store
store.load();
// I get the values of the store
var records = [];
store.each(
function (r)
{
records.push (r.copy());
});
// I try to copy the values in my second store but it doesn't copy it
storeForGrid.loadRecords(records);
console.log(store);
console.log(storeForGrid);
Is there another way to do this action, it seems so simple to do it. But I wonder if extjs is able to do this kind of thing.
Any help would be greatly appreciated.
Regards
I have this issue for 2 days now and nothing seems to work.
What I want to do is very simple. I have 2 stores. I use the first one with a proxy to get data from DB.
Then I want to copy the datas I have retrieved to another store that I will link to a grid to display the data. I want to do this to avoid calling the database to much times.
Unfortunately I can't achieved that.
My first store
Ext.define('TAB.store.MetrSeriesStore', {
extend: 'Ext.data.Store',
requires: 'TAB.model.SerieGridModel',
model: 'TAB.model.SerieGridModel',
storeId: 'metrSeries',
groupField: 'CODEFC',
buffered: true,
pageSize: 100,
proxy: {
type: 'ajax',
url: 'app/data/loader.cfc?method=getMetrSeries&returnformat=json',
reader: {
type: 'json',
root: 'DATA'
}
}
});
The second store (should I also use a proxy to copy data in this one? )
Ext.define('TAB.store.MetrSeriesDisplayedStore', {
extend: 'Ext.data.Store',
requires: 'TAB.model.SerieGridModel',
model: 'TAB.model.SerieGridModel',
storeId: 'metrSeriestoDisplay',
proxy: {
type: 'rest',
reader: {
type: 'json',
root: 'data'
}
}
});
My controller that tries to copy data's
var store = Ext.getStore('MetrSeriesStore');
var storeForGrid = Ext.getStore('MetrSeriesDisplayedStore');
store.proxy.extraParams = {
codes : Global.codeListToLoad
}
// I load data in my first store
store.load();
// I get the values of the store
var records = [];
store.each(
function (r)
{
records.push (r.copy());
});
// I try to copy the values in my second store but it doesn't copy it
storeForGrid.loadRecords(records);
console.log(store);
console.log(storeForGrid);
Is there another way to do this action, it seems so simple to do it. But I wonder if extjs is able to do this kind of thing.
Any help would be greatly appreciated.
Regards