Refresh Branch

I need to refresh a branch of a tree. I’ve tried refreshItem, this creates a duplicate of the branch. I’ve tried smartRefreshitem, and smartRefreshBranch but nothing happens. I’m however able to refresh the entire tree.

This is my code for initiating the tree:

tree4=new dhtmlXTreeObject(document.getElementById(‘treeBox_4’),“100%”,“”,0);







The code is correct and must not cause any problem.
Are you using refreshItem agains opened branch, or agains one, which never was loaded from server yet?
In second case problem with duplication may really occurs ( the XML will be loaded twice - one by refreshItem command, second automatically while opening item )

You can try to use next code snippet
if (tree.hasChildren(id) === true)

It will open item if it was never opened before, and will call refreshItem if item was already loaded.
Such approach must prevent duplication.

I’m always refreshing an open branch.

Well, refreshItem() actually works on branches, but it has the unwanted sideeffect that it duplicates the top-level items. I tried using smartRefreshItem but nothing seems to happen(?)

Both smartRefreshItem and smartRefreshBranch commands updated items in tree based on their IDs.
Please be sure that
    a) response XML has tree@id pointed to updated branch ID
    b) the item@id in response XML must be the same as IDs of items , which need to be updated