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'?>


































Hello,


the issue wasn’t reproduced locally. Please, provide the sample that re-creates the issue to support@dhtmlx.com

Hi, Ive already sent email support@dhtmlx.com
subject= forum question 24 jun wrt smartRefreshBranch‏

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'?>

   
   
   
   
   
       
       
   



sample.html
===========

















Hello,


Please, method timeoutRefreshTree(); can be called only after xml loading:


tree.loadXML(“tree3.xml”,timeoutRefreshTree);


instead of


tree.loadXML(“tree3.xml”);
timeoutRefreshTree();



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?


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”);

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.


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


Hello,


sorry. it was my typo. I meant:


if(!tree1.getXMLState()) tree1.smartRefreshBranch(0,“tree3.xml”);

if(!tree2.getXMLState()) tree2.smartRefreshBranch(0,“tree3.xml”);



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?

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.
patch.zip (700 Bytes)

Can you pls. send me demo for this. i have tree pro js file too but not working on my end.

email me on hemant123.patil@gmail.com