PDA

View Full Version : Documentation TreePanel



rahulmca1@gmail.com
4 Feb 2007, 8:45 PM
Hi,

I am tring to see how TreePanel works

Cant get how actually Tree.TreeLoader({dataUrl:'get-nodes.php'}) worls in the code below
In my case I am using java at server side and sending back xml having info about tree hirerachy.


var tree = new Tree.TreePanel('tree-div', {
animate:true,
loader: new Tree.TreeLoader({dataUrl:'get-nodes.php'}),
enableDD:true,
containerScroll: true

Where can I find more documentation so that I can understand TreePannel better

Thanks

tryanDLS
4 Feb 2007, 9:04 PM
The Tree is still alpha code. You will have to refer to the example or the pre-.40 doc which has a little bit of Tree doc - otherwise you'll just have to try and read the code and read previous posts regarding the tree.
http://www.yui-ext.com/playpen/yui-ext.0.40/docs/

JeffHowden
4 Feb 2007, 11:51 PM
Cant get how actually Tree.TreeLoader({dataUrl:'get-nodes.php'}) worls in the code below In my case I am using java at server side and sending back xml having info about tree hirerachy.

The TreeLoader will make a POST request to the dataURL supplied. At a minimum, it will include a node field.

Once the treePanel is defined, you must define the root:


var root = new Tree.AsyncTreeNode({
text: 'Root'
, draggable:false
, id:'root'
, cls: 'root'
});
tree.setRootNode(root);

Then, you must render the tree:


// render the tree
tree.render();


The treeLoader expects a response in JSON format. It should look like this:


[{"id":"someid","text":"sometext","leaf":false}]

Optionally, you can return a cls property to use to define an additional class for the node which you can use to alter the icon:


[{"id":"someid","text":"sometext", "cls": "someclassname","leaf":false}]

rahulmca1@gmail.com
5 Feb 2007, 6:01 AM
Thanks for such a nice explaination

My question is

can I use xml instead of json for sending nodes hirerachy

e.g

Supose my xml is :--
<plist>



<s>1</s>
<s>2</s>
<s>3</s>
</p>
</plist>

can i usen it for creating nodes hirerachy.


Thanks

BernardChhun
5 Feb 2007, 7:03 AM
can I use xml instead of json for sending nodes hirerachy
Correct me if I'm wrong but I think the answer is no here. But that doesn't mean it won't be supported later on.



can i usen it for creating nodes hirerachy.


yes, use the children attributes to do so:


{text: "node", children: [{text: "childNode"}]}