PDA

View Full Version : Loading Dynamic Data for Tree



akhildmx
10 Mar 2011, 4:26 PM
Hi All,

I am new to Extjs, I want to load data dynamically into the tree. The server returns me data, which is not in json format i.e the structure of data is pretty much messed up. What URL should i specify in my code and how do i deal with the format of data. There is no way to differentiate between parent and child by going through the data. I am trying to build a tree based on following code...

Ext.onReady(function()
{

var Tree = Ext.tree;

var tree = new Tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl:'???????????',

root: {
nodeType: 'async',
text: 'ALL',
draggable: false,
id: ''
}
});

// render the tree
tree.render('tree-div');
tree.getRootNode().expand();

});

haiyupeter
10 Mar 2011, 8:41 PM
maybe this sample can help!
http://dev.sencha.com/deploy/dev/examples/grid/paging.html

emils
10 Mar 2011, 10:46 PM
dataUrl is URL of your server side script, who must return something like this:



[{
text:'Node Name or something ...',
expanded: true,
singleClickExpand: true,
children:[{
text:'Node Name or something ...',
leaf:true
}]
},{
text:'Another one',
expanded: true,
singleClickExpand: true,
children:[{
text:'First children',
expanded: false,
singleClickExpand: true
},{
text:'Second children',
expanded: false,
singleClickExpand: true
}]
}]



for more information see TreeNode.

akhildmx
11 Mar 2011, 11:18 AM
Thanks for the tip. I am getting the data from the sever as JS array. The new problem is that how do I make the parent node have a folder icon. Where do i put "cls: folder" in my code.