PDA

View Full Version : Ext4 TreeStore display problem



silenceleaf
4 Aug 2013, 6:53 PM
my Json:




{"id":0,"node_type":0,"depth":0,"parentId":0,"node_index":0,"expanded":"true","checked":"true","text":"root","children":[{"id":1,"node_type":2,"depth":1,"parentId":0,"node_index":0,"expanded":"true","checked":"true","text":"leaf","leaf":"true"},{"id":2,"node_type":1,"depth":1,"parentId":0,"node_index":1,"expanded":"true","checked":"true","text":"children-1","children":[{"id":3,"node_type":2,"depth":2,"parentId":2,"node_index":0,"expanded":"true","checked":"true","text":"leaf-11","leaf":"true"}]}]}

My Javascript code:



var funcTreeStore = Ext.create('Ext.data.TreeStore', {
model: 'funcTreeModel',
defaultRootId: '0',
proxy: {
type: 'ajax',
url: '/main/functionTree.json',
reader: {
type: 'json',
root: 'children'
}
}
});


var funcTree = Ext.create('Ext.tree.Panel', {
region: 'west',
collapsible: true,
title: 'Navigation',
width: '20%',
split: true,
store: funcTreeStore,
margin: '0 0 5 0'


The Correct tree should like this :
45196


But when I use AJAX proxy TreeStore, my tree display like this:
45197

the leaf node "leaf-11" is missing

Anyone can tell me, what's wrong, thanks a lot!

aaugen
5 Aug 2013, 12:34 AM
Hi,

Don't use children like json root on your json reader, prefer root value with json like this:


root: {
expanded: true,
text: "My Root",
children: [
{ text: "Child 1", leaf: true },
{ text: "Child 2", expanded: true, children: [
{ text: "GrandChild", leaf: true }
]}
]
}