View Full Version : JSON Data for GridPanel

20 Oct 2010, 7:11 AM
Hello guys,

My server returns a JSON string like

rows: [
{first: "first1", company: "anyCompany", last: "last1", email: "somebody@somebody.com", datagrids: [{ name: "myName1", surname: "mySurname1"},{ name: "myName2", surname: "mySurname2"}] }


In my application I have a GridPanel (2 column Indexes 'name' and 'surname')with JsonReader:

new Ext.data.JsonReader({
root: 'rows',
{ name: 'name', mapping: 'grids.name' },
{ name: 'surname', mapping: 'grids.surname' }

But the grid is not filled with the above json data (the rest properties of the json are used for filling the textfields of a form)

20 Oct 2010, 7:18 AM
grids -> datagrids

20 Oct 2010, 7:23 AM
Hello Animal,
I have tried "datagrids" but it has no effect. Is the syntax correct?

20 Oct 2010, 7:27 AM
You could use:

but I doubt that's what you really want.

I think you are looking for:

new Ext.data.JsonReader({
root: function(data) {
var root = [];
for(var i = 0; i < data.rows.length; i++){
root.push.apply(root, data.rows[i].datagrids);
return root;
fields:['name', 'surname']

20 Oct 2010, 7:34 AM
It works!
Thank you very much Condor,
It was really helpful!!!!