PDA

View Full Version : Tree Grid with different JSON Format



sarasa
23 May 2013, 9:25 AM
Hi,

I have read sencha docs and learn how to render a tree grid.
And also i was able to render the tree grid with json data format shown in the site.
But i have a different json format as below, like children tag will contain the main name of the children which is in same json.
How can i populate this in tree grid? I am little confused. The structure of json cannot be changed.
Can you pls help?


{

"orderby": [],
"filter": ["parent"],
"collection": [{
"maintitle": "123",
"parent": "333",
"children": [
{"idx": 0,"maintitle": "201"},
{"idx": 1,"maintitle": "202"}
],
"title": {
"name": "ABC",
"field1": true,
"field2": [],
"field3": [],
"field5": []
}
},{
"maintitle": "201",
"parent": "123",
"title": {
"name": "DCF",
"field1": true,
"field4": "someval",
"field2": [{
"maintitle": "val",
"title": {
"name": "val",
"category": "Web"
}
}],
"field3": [{
"maintitle": "val",
"title": {
"name": "val",
"category": "mail"
}
}],
"field5": []
}
},{
"maintitle": "202",
"parent": "123",
"title": {
"name": "GHI",
"field1": true,
"field4": "val",
"field2": [{
"maintitle": "val",
"title": {
"name": "val",
"category": "val"
}
}],
"field3": [{
"maintitle": "val",
"title": {
"name": "val",
"category": "val"
}
}],
"field5": []
}
}]
}

slemmon
28 May 2013, 9:49 AM
I believe you can set the root to be whatever you'd like. Check out the "Reading Nested Data" sub-section at the top of the TreeStore API docs for a description.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.TreeStore