Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Geoffrey Graff on May 23, 2008 00:52
open dhtmlx forum
dhtmlxTree best way of tree building

Hi,

What's the best way to build a tree ?
1.
var tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%","ROOT");
tree.setImagePath("imgs/");
var t = tree.insertNewChild("ROOT","NODE1","New Node 1",0,0,0,0,"");
t = tree.insertNewChild("NODE1","NODE2","New\"'' Node 2",0,0,0,0,"");

2.
var tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%","ROOT");
tree.setImagePath("imgs/");
tree.loadXMLString("<tree id='ROOT'><item id='1' text='Node1'><item id='2' text='Node2'></item></item></tree>");

In my first sample, all items are opened. I try to add value CLOSE in the optionString parameter but it does'nt work.
tree.insertNewChild("ROOT","NODE1","New Node 1",0,0,0,0,"CLOSE");
How to do ?

Can I use performance methods like enableSmartRendering when I use insertNewItem method ?

Thanks


Answer posted by Support on May 23, 2008 02:39

Basically the both approaces are correct, but second one a bit faster. 

>>In my first sample, all items are opened
When items added one by one, component will automatically expand branches , can be changed by 

tree.openOnItemAdded(false);
tree.insertNewChild(...

>>I use insertNewItem method
No, both smartXMLParsing and smartRendering will work only in case of loading from external source