Question

Can data that DynaTree uses be changed dynamically?

I have a complete set of data that relates to dynatree, but I want to display only a certain branch of the tree so I iterate over the data and take the node I want and create the tree, this works fine.

What I would like to do is have a button that makes the siblings of the current node visible. essentially a user is in charge of one node which they see by defaault, but they can see siblings of the current node if they need too.

I can re-iterate over the data and select the parent node and set the data to the parent but the tree doesnt update.

I've tried:

tree.reload();
tree.renderInvisibleNodes() 
tree.redraw();

and setting the element to empty and recreating the tree with the new settings

 $('#i2o-tree').empty();
 $('#i2o-tree').dynatree(new_settings);
Was it helpful?

Solution

Just got this to work, Hope this helps someone in future.

Since dynatree is a jQuery plugin, if you really need to reload the data and re-render the tree you and call jQuery's 'destroy' method:

 // destroy tree
 $("#i2o-tree").dynatree("destroy");

 // re-create tree with new settings/data
 setupTree(tree_data, false);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top