Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Israel on Jan 05, 2010 01:36
open dhtmlx forum
refresh tree item and all his childs

I'm creating a tree using the script:
tree.loadXMLString(res,function(){tree.loadOpenStates()});

Later in the server I'm updating specific branch, and want the tree to refresh only this branch.
I'm using the method:

tree.refreshItem(parentId,sRes);

Where parentId is: 3823276648
And sRes is:
<item text="something" id="3823276648" im0="Linux.gif" im1="Linux.gif" im2="Linux.gif">
<item text="child1" id="11111" im0="1.gif" im1="1.gif" im2="1.gif">
</item>

The parent node is refresh but all his childs disapear.
Should I use diffrent method.

My dhtmlXtree version is: dhtmlxTree_pro_v16_71114

Thanks
Answer posted by Alex (support) on Jan 05, 2010 03:06

refreshItem method can be used only with dynamic loading. And it doesn't have the 2nd parameter.

You can use either refreshItems method to update ceratin items or smartRefreshBranch to refresh the whole branch:

tree.refreshItems(parentId,sRes);

tree.smartRefreshBranch(parentId,sRes);

Answer posted by israel on Jan 05, 2010 06:04

This doesn't work,

1. tree.refreshItems(parentId,sRes);  - refresh only the parent node and not the children, I can see it also in your supplied samples.

2. tree.smartRefreshBranch(parentId,sRes); - returns the following error: error load XML

I'm passing the String:

<item text="something" id="3823276648" im0="Linux.gif" im1="Linux.gif" im2="Linux.gif">
<item text="child1" id="11111" im0="1.gif" im1="1.gif" im2="1.gif">
</item>

as the second argument, should I call servlet that will return the string?


 

 

Answer posted by Alex (support) on Jan 05, 2010 06:18

The second parameter of the smartRefreshBranch and refreshItems method is path server-side script that returns the necessary xml:

for example:

tree.smartRefreshBranch(parentId,some_script+"?id="+parentId);

The example of the xml:

<tree id="382327664">

   <item text="something" id="3823276648" im0="Linux.gif" im1="Linux.gif" im2="Linux.gif"> 
      <item text="child1" id="11111" im0="1.gif" im1="1.gif" im2="1.gif"></item>

   </item>

</tree>

Answer posted by Israel on Jan 05, 2010 07:54
Thanks, the solution wokred