I have a Dojo tree in which I change icons depending on item values with the getIconClass method:
_tree = new Tree({
model: _model,
getIconClass: function(item) {
if (item.completed) {
return "iconCompleted";
} else if (item.launched) {
return "iconIncomplete";
} else {
return "iconInitial";
}
}
}, div_id);
I'm searching a way to refresh the tree view when the item properties change, for now I found this:
refreshTree : function(){
_tree.rootNode.destroyRecursive();
_tree.model.constructor(_tree.model)
_tree.postMixInProperties();
_tree._load();
}
This function refresh the tree, but it actually rebuild the view, so:
- The tree makes time to shows up again
- Expanded nodes states are reinitialized
So my question is : What would be the method to update the tree dynamically instantanly with keeping the expanded node states?
I started writing something to get expanded nodes states, but when I need to set the expanded nodes states again, as the tree view makes time to shows up, I would need a callback to know when tree view is finished to appear, and I didn't found it. BTW is there a propriety to make the tree view appears instantanly?
If you only want to change the icon there is no need to recreate the tree. You can wrap your store with Observable and the tree will be notified when the store data change. To update an item use the store.put() function.