Alex, the tree refresh code you supplied works gereat ie -- tree.saveOpenStates(); // save tree open nodes tree.deleteChildItems(0); // delete tree tree.loadXML // load tree first level tree.loadOpenStates(); // reopen nodes -- its good but it is it possible to make it even better? i.e. if you have alot of tree nodes open then refresh the tree using the abpve code you then see 1. tree with many open nodes dissappears 2. tree reappears but wit all nodes closed 3. tree nodes start to ripple open Is there a way of avoiding this? I was wondering if maybe for example a temporary hidden tree could be loaded with the refreshed tree and once loaded swapped with the visisble tree so that the refreshed tree appears fully open?
tree.saveOpenStates(); // save tree open nodes tree.deleteChildItems(0); // delete tree tree.loadXML // load tree first level
/shows tree when items are opened (loaded)/ tree.attachEvent(“onAllOpenDynamic”,function(){ tree.allTree.style.visibility = “visible” }) tree.loadOpenStates(); // reopen nodes
Hi Alex, thanks the code worked, with a tweak - as below - but I think
I prefer to see the tree refreshed and the nodes rippling back open
rather than have no tree visibile for many seconds.
Is it not possible to either 1) Freeze the tree on display until its refreshed? 2) Or else use two trees i.e. instead of making the tree
invisible, keep showing it while a second tree is refreshed and once
refreshed switch to displaying the refreshed tree? Something like below- which does not work…
var mytree = new dhtmlXTreeObject(“mytreeHidden”,“0%”,“0%”,0); mytree.setXMLAutoLoading(); mytree.attachEvent(“onXLE”,function(){ tree=mytree; }); mytree.loadXML(“xml/diratreeall.php”);
–tweaked last post code if (!tree.getXMLState()) { tree.saveOpenStates(); tree.deleteChildItems(0); tree.allTree.style.visibility = “hidden”; tree.loadXML(",function(){ tree.loadOpenStates(); }); tree.attachEvent(“onAllOpenDynamic”,function(){ tree.allTree.style.visibility = “visible”; }); }
function showTempTree(mode){ if(mode){ var xml = tree.serializeTree() tree1.deleteChildItems(0); tree1.loadXMLString(xml); document.getElementById(“treeboxbox_tree1”).style.display=""; } else document.getElementById(“treeboxbox_tree1”).style.display=“none”; }
unfortunatey tree doesn’t provide ready solutions to do that. The customization can be done only for additional fee. If you are interested in it, please contact us at sales@dhtmlx.com
I create a tmp tree just for loading XML+saved states which I put into a string for loading into my tree.
atree = leftLayout.cells(“a”).attachTree(“0”); // my tree tmpTree = layout.cells(“b”).attachTree(“0”); // just for loading
// save my tree states atree.saveOpenStates(); // save tree open nodes
// load tmp tree + saved states and serialise tmpTree.deleteChildItems(0); // delete tree tmpTree.loadXML // load tree first level tmpTree.loadOpenStates(); // reopen nodes var xmlString = tmpTree.serializeTree();
// load my tree ie load tmpTree serialised string atree.deleteChildItems(0);
tree.loadXMLString(xmlString );
But I’ve noticed that performance is severly hit the more open nodes that need to be saved/loaded (cookie). Whereas loadXMLString is pretty fast. Any suggestions on improving performance?