PDA

View Full Version : Processing arbitrary data after store load



xpouj04
13 Feb 2012, 3:22 AM
Hi,
I have a grid with store with defined proxy:

proxy: {
type: 'ajax',
url : 'xqy/get-ds-data.xqy,
reader: {
type: 'json',
root: 'data'
}
}

I would like to generate response something like this:

{
"success": true,
"total": 7,
"data": [{ ... }],
"otherData": [{ ... }]
}

Then, I would like to set up a load listener in the store, where I could process the "otherData". Is it possible?
(When generating data for grid I would like to generate at the same time data for corresponding chart..)

Thanks for help!
Jan

mitchellsimoens
13 Feb 2012, 4:51 AM
store.on('load', function(store) {
var reader = store.proxy.reader,
getOtherData = reader.createAccessor('otherData')(reader.rawData);
});

Just typing from the top of my head. The part I'm not 100% is getting the rawData. Pretty sure it's saved on the rawData.

xpouj04
13 Feb 2012, 7:41 AM
Thanks Mitchell, it works :-)