Categories | Question details Back To List | ||
performance: dynamic tree loading and refreshing current level [ Topic already exists - interactive mode on existing topic not showing 'Answer' , see: Stephen, posted: Nov 05, 2009 07:36 | Direct link: index.php?s=normal&q=12692&a=20605 ] 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? Answer posted by Alex (support) on Nov 09, 2009 05:19 Hello, you can try to use the following approach: /*hides tree*/ Answer posted by Stephen on Nov 09, 2009 06:51 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... <div id="mytreeHidden"></div> var mytree = new dhtmlXTreeObject("mytreeHidden","0%","0%",0); mytree.setXMLAutoLoading(<load first level tree>); 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(<load first level tree>",function(){ tree.loadOpenStates(); }); tree.attachEvent("onAllOpenDynamic",function(){ tree.allTree.style.visibility = "visible"; }); } Answer posted by Alex (support) on Nov 09, 2009 08:23 You can try to use two trees as you described. For example (but the following method wasn't tested locally): <div style="width:260px; height:260px;position:relative;"> .. tree.saveOpenStates(); Answer posted by Stephen on Nov 09, 2009 10:52 Trying to see how I can use this but problem is I'm not using <div> I'm using tree = leftLayout.cells("a").attachTree("0"); Answer posted by Alex (support) on Nov 10, 2009 01:44 Hello, 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 Answer posted by Stephen on Nov 17, 2009 03:47 Alex I've a solution. 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? Answer posted by Alex (support) on Nov 17, 2009 06:50 Unfortunately tree doesn't provide any other solution. loadOpenState method restores all open states (this is your requirement) and rendering can take time if open structure is rather big. Answer posted by Stephen saveOpenStates on Nov 19, 2009 03:10 Regarding loadOpenState restores all open states and rendering can take time if open structure is rather
big. It appears saveOpenStates is for the whole tree or is it possible to only save from a selected node and the tree below? Answer posted by Alex (support) on Nov 19, 2009 03:33 Both methods can be used only for the whole tree. If the selected branch doesn't contain a lot of nodes, you can try to use smartRefreshBranch for it. |