Categories | Question details Back To List | ||||||||
dhtmlxTree malformed tree - smartRefreshBranch tree.loadXML("tree.xml"); works but tree.smartRefreshBranch(0,"tree.xml"); does not (note I want smartRefreshBranch as this is called at regular intervals to update tree biut note the problem occurs without the timed refreshes ie just call it once) The tree xml has 3 items and 1 sub item = help, but the tree shows 1 item books and 3 sub items. XML === :- paper :- magazines :- books --\--help Tree ==== :- books \--help --:-- paper --:- magazines V If books folder is closed then there is just books in the tree. There is a space between help and paper. The line connecting paper and magazines goes downwards not upwards. the XML --------- <?xml version='1.0' encoding='iso-8859-1'?> <tree id="0"> <item text="Paper" id="paper" open="1" im0='folderClosed.gif' im1='folderOpe n.gif' im2='folderClosed.gif'> </item> <item text="Magazines" id="magazines" open="1" im0='folderClosed.gif' im1='f olderOpen.gif' im2='folderClosed.gif'> </item> <item text="Books" id="books" open="1" call="1" select="1" im0='folderClosed .gif' im1='folderOpen.gif' im2='folderClosed.gif'> <item text="help" id="help" open="1" im0='folderClosed.gif' im1='fol derOpen.gif' im2='folderClosed.gif'> </item> </item> </tree> Answer posted by Alex (support) on Jun 25, 2009 03:12 Hello, the issue wasn't reproduced locally. Please, provide the sample that re-creates the issue to support@dhtmlx.com Answer posted by Stephen on Jun 25, 2009 03:57 Hi, Ive already sent email support@dhtmlx.com subject= forum question 24 jun wrt smartRefreshBranch Answer posted by Stephen on Jun 25, 2009 06:50 Please try out the following sample - btw I have treepro dhtmlxtree.js v.2.0 build 81009 tree3.xml ========= <?xml version='1.0' encoding='iso-8859-1'?> <tree id="0"> <item text="Paper" id="paper" open="1" im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'> </item> <item text="Magazines" id="magazines" open="1" im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'> </item> <item text="Books" id="books" open="1" call="1" select="1" im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'> <item text="help" id="help" open="1" im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'> </item> </item> </tree> sample.html =========== <html> <body> <link rel="STYLESHEET" type="text/css" href="codebase/dhtmlx.css"> <link rel='STYLESHEET' type='text/css' href='codebase/dhtmlxtree.css'> <script src="codebase/dhtmlx.js"></script> <script src='codebase/dhtmlxcommon.js'></script> <script src='codebase/dhtmlxtree.js'></script> <script src="codebase/dhtmlxtree_ed.js"></script> <script> function doOnLoad() { layout = new dhtmlXLayoutObject(document.body, "2U"); tree = layout.cells("a").attachTree("0"); tree.setImagePath("codebase/imgs/"); tree.setImagePath('codebase/imgs/'); tree.loadXML("tree3.xml"); timeoutRefreshTree(); } function timeoutRefreshTree() { tree.smartRefreshBranch(0,"tree3.xml"); var time=setTimeout("timeoutRefreshTree()",3000); } window.onload=doOnLoad; </script> </body> </html> Answer posted by Alex (support) on Jun 25, 2009 07:17 Hello, Please, method timeoutRefreshTree(); can be called only after xml loading: tree.loadXML("tree3.xml",timeoutRefreshTree); instead of tree.loadXML("tree3.xml"); Answer posted by Stephen on Jun 25, 2009 07:52 Thank you very much Alex, that worked. One question what if you have two trees and both need refreshing using the same timeout func? Use this: onetree.loadXML("tree1.xml"); twotree.loadXML("tree2.xml",timeoutRefreshTree); and not onetree.loadXML("tree1.xml",timeoutRefreshTree); twotree.loadXML("tree2.xml",timeoutRefreshTree); or neither? Answer posted by Alex (support) on Jun 25, 2009 08:31 Trees are loaded asynchronously. So, it is possible that timeoutRefreshTree for the second tree will be called before the first one is loaded. If the refresh function is called regularly, you can place a check of a loading state before smartRefreshItem call: if(!tree1.getXMLState) tree1.smartRefreshBranch(0,"tree3.xml"); if(!tree2.getXMLState) tree2.smartRefreshBranch(0,"tree3.xml"); Answer posted by Stephen on Jun 25, 2009 09:29 Alex did you mean if(!tree1.getXMLState) tree1.smartRefreshBranch(0,"tree3.xml"); as it appears to always be true. From : dhtmlXTreeObject.prototype.getXMLState=function(){ return (this.xmlstate==1); }; I checked this.xmlstate and this appears to be always =0 when the refresh func is entered. There is also if (!tree1.waitUpdateXML) tree1.smartRefreshBranch(0,"tree3.xml"); but the browser has tree1.waitUpdateXML as undefined when the refresh func is entered. Answer posted by Stephen on Jun 25, 2009 11:40 Re : if (!tree1.waitUpdateXML)
tree1.smartRefreshBranch(0,"tree3.xml"); [Using firebug] browser now has tree1.waitUpdateXML as being defined now!? Its working in that if I make changes the tree picks them up but then waited 30 mins or so and it has stopped working in that browser has tree1.waitUpdateXML as always true - with no changes I make a change now and the xml is not loaded Answer posted by Alex (support) on Jun 25, 2009 23:10 Hello, sorry. it was my typo. I meant: if(!tree1.getXMLState()) tree1.smartRefreshBranch(0,"tree3.xml"); Answer posted by Stephen on Jun 27, 2009 12:57 Sorry yes getXMLState() But I still have a possible problem using tree1.getXMLState()in that it - start off false but after a time (not determined how long) - starts to always be true and so theres no refresh. The refresh is every 4 secs and theres only a small amout of data 20/30 lines. Refresh the browser gets it back to returning false. Why would it always return true? Answer posted on Jun 29, 2009 06:46 Please try to use attached patch ( just add its content to the end of dhtmlxtree.js or include on the page after other js files ) - it must fix issue with locked xml-state value. Attachments (1)
|