PDA

View Full Version : TreeStore and custom JSON



da_b0uncer
6 Jul 2012, 4:55 AM
I have a custom JSON structure, which is hirarchical.
The tree is wrapped in an object, that also contains a status code and stuff.

I want to get the "value" content with all its children into the tree, but I encountered a problem.

The first one is, the value object gets parsed and converted into a model instance, but it's children don't. They end up in the "data" section of the model instance, like the other attribute (name, path, etc.)



{
"status":{
"status":0,
"msg":"Ok"
},
"value":{
"children":[
{
"path":"KEY_518693",
"name":"KEY_518693",
"children_count_overall":0,
"children_page":1,
"children_pages":1,
"children_pagesize":10
}
],
"children_count_overall":1,
"children_page":1,
"children_pages":1,
"children_pagesize":1,
"name":null,
"path":null
}
}


The Store is configured with an Ajax proxy, that uses an json reader with root: "value".



And this is, what the tree in the store looks like, after it loaded the first nodes:

constructor


childNodes: Array[1]

0: constructor

childNodes: Array[0]
data: Object

allowDrag: true
allowDrop: true
checked: null
children: Array[1]

0: Object

children_count_overall: 0
children_page: 1
children_pages: 1
children_pagesize: 10
data: Array[1]
header: Array[4]
name: "KEY_518693"
path: "KEY_518693"
...





?When I set the root of the proxy to "value" and keep the default rootProperty in the store, I get the root and childnodes, but only if I rename the "children" attribute in the JSON answer to "value".

when I have "value" with "children" with "children" use "value" als root in the proxy and "children" als rootProperty in the treestore it doesn't work.