PDA

View Full Version : Loading a Tree using JSON via AJAX call



harman
1 Mar 2012, 2:59 AM
Hi All,

I have a requirement to load a Tree using tree store that gets JSON data from the server using an AJAX call.
What should be the Format of JSON that i send from controller and what should be the store config for it?

The Visual Structure would be something like
User 1
User 2
Group 1
User 3
User 4
Group 2
User 5

and so on.
This would be a dynamic structure.

Help me out guys.

Thanks

mitchellsimoens
1 Mar 2012, 11:30 AM
You should use http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.TreeStore

JSON should be something like:


{
"children" : [
{
"text" : "Test",
"leaf" : true
},
{
"text" : "I have children",
"children" : [
{
"text" : "foo",
"leaf" : true
}
]
},
{
"text" : "I have no children but can hold some",
"children" : []
}
]
}