PDA

View Full Version : Passing store data to server side



harjits
21 Nov 2012, 7:11 AM
Hi there,

I have a grid whose store definition is as follows


this.store = new Ext.data.JsonStore({
autoload : false,
idProperty : 'groupID',
root : 'Name_report',
totalProperty : 'count',
successProperty : 'success',
messageProperty : "msg",
autoScroll:true,
fields : [
{
name : 'entityID'
},{
name : 'groupID'
}, {
name : 'groupName'
}, {
name : 'originalName'
}, {
name : 'standardName'
}
],
remoteSort : false,
proxy : new Ext.data.HttpProxy({
url : QUERY_URL +"?type=NAME",
defaultHeaders : {
Accept : 'application/json'
},
method : 'post',
disableCaching : false
})
});


I want to send the json representation of the store data to the server for generating reports. Is there any way I can do that ?

willigogs
21 Nov 2012, 7:27 AM
I'm not sure I understand what you want to send to the server?

Can you give an example of what you expect to send?

harjits
21 Nov 2012, 7:53 AM
I need to pass the data contained in the store

willigogs
21 Nov 2012, 8:02 AM
You need to pass the entire dataset held in the store? I'm not sure why you would need to do that - since it must already be populated by a call to a DB anyway?

Why are you wanting to send every record?

harjits
21 Nov 2012, 8:06 AM
That's what I need to know, how can I pass the entire data set. I can't query the DB again because in sme cases the query takes time to fetch the results and hence I don't want to query the DB again to fetch the data. Hence I need to pass the data which is contained in the store as JSON or some other format to the server to generate PDF.

willigogs
21 Nov 2012, 8:18 AM
Yes, this is possible.


// GRAB THE DATA OBJECT
var data = store.reader.jsonData;
// CONVERT TO JSON STRING
var str = Ext.util.JSON.encode(data.Name_report);


Then simply pass the str variable during your call to create the report.

harjits
21 Nov 2012, 9:04 AM
That worked thanks....