PDA

View Full Version : loading TreePanel with json data



endrem
5 Aug 2013, 10:33 PM
I have defined a TreePanel:
<code>
var nordicSeaTree = new Ext.tree.TreePanel({
width: 200,
id:'nordicSeaMarineAtlas',
autoScroll: true,
split: true,
loader: new Ext.tree.TreeLoader(),
root: new Ext.tree.AsyncTreeNode({
text: "fish",
expanded: true,
children: "${species.name}"
}),
rootVisible: true,
});
</code>
where spescies.name="[{text:\'First Level Child 1\',leaf: true}]"
Instead of getting root: "fish" and one child element "First Level Child1" I get many children under "fish" one for each character in species.name. like so: "fish" -> "[", "{", "t","e","x","t"... and so on


Any idea what im doing wrong? Im trying to populate the treePanel with json objects from the server. Pretty basic. But cant get it working...

scottmartin
7 Aug 2013, 10:03 PM
Your json is invalid:

try


[
{
"text": "FirstLevelChild1",
"leaf": true
}
]