Where can I get an free smartRefreshItem method for my tree?

I would really need it or at least some kind of its approximation;



Thx


The standard version of tree provides only
tree.updateItem(…
method, which fully reloads branch from server.

The smartRefreshItem call , can be partially simulated by
tree.waitUpdateXML=true;
tree.updateItem=function(id,text){ tree.setItemText(text); };
tree.loadXML(some);


I have a data model which I represent in a tree by generating xml outputs on the server and by sending them back to the browser over http;

The model of the tree being completely decoupled from the view (the js dhtmlxtree), I need to be able to seamlessly push new changes back into the tree whenever my actions refresh the model. I could of course use the simpleRefresh() method but the problem is that is collapses all the subbranches that were already opened and isn’t very neat visually speaking (no state keeping whatsoever). This is why I would very much appreciate having a method such as smartRefreshBranch/Item (didn’t really get which one of them responds better to my needs) so that the root node gets cleanly updated (stick the new and remove the old nodes into the tree without no clumsy flicking on the screen) once the model has been adapted.

I tried the code above with the tree.setXMLAutoLoading(url) URL as parameter but it doesn’t seem to work;

If you guys could just provide me with the right method code to do my job, I would be very greatfull and my chiefs would have a real argument acquiring a fully flegded library of your app;


Thanks

I get an undefined object error when using your code;

Please check attached sample
1222938584.zip (47.6 KB)

stick the new and remove the old nodes into the tree without no clumsy flicking on the screen
The solution provided above is able to update and add new items, it still not able to delete not existing items, this can be done only with pro version of tree.

Thank you very much guys;

Even without the delete, this smart refresh is a killer :slight_smile:

Although it looks like it is having some troubles refreshing branches programmatically.

Although it looks like it is having some troubles refreshing branches programmatically.
The above solution is kind of hack, so it may fail in complex scenarious.
You can try to add the next line of code, it must resolve problem with branch updating
tree.smartRefreshItem=function(itemId,source){
if (source && source.exists)
this._parse(source,itemId);
}