PDA

View Full Version : Best practices for receiving data from the server



KPradel
1 Dec 2010, 11:54 AM
I am fairly new to Ext JS and am trying to wrap my head around the best way to consume data from my application server.

I am calling a server side method called "getmetadata" to retrieve json formatted data. The data contains many name value fields and one array, called "mdarray". I am able to display the contents of "mdarray" in my gridpanel without a problem. However, since I am telling the JSON Reader to use "mdarray" as the root note, I seem to be unable to get to the data before or after "mdarray".

So my question is: how can I point once JSON Store to one root but still access the data surrounding that root node?



var metadatastore = new Ext.data.JsonStore({
url: 'components/api.cfc?wsdl',
baseParams : {'method' :'getmetadata'},
root : 'MDARRAY',
fields: ['PROXYSOURCE', 'KEY', 'VALUE'],
}
});

var metadatagrid = new Ext.grid.GridPanel({
frame : true,
height : 300,
autoExpandColumn: true,
store : metadatastore,
colModel: new Ext.grid.ColumnModel({
defaults : {
sortable: true
},
columns : [
{header : 'Key', dataIndex: 'KEY'},
{header : 'Value', dataIndex: 'VALUE'}
]
})
})
Ideally, I'd like to define two data stores but only have one request to the server. Is that possible? Any help is much appreciated

Kai

filippo.ferrari
1 Dec 2010, 1:33 PM
Hallo, read this: http://www.sencha.com/forum/showthread.php?117248-How-to-use-a-response-data-in-a-grid-toolbar&p=545403

I've solved a similar question using beforeload event. :)