Reputation: 51
I have three nodes in the tree and would like to keep the first node expanded, is there a way in dojo tree which would support this?
Thanks.
Upvotes: 0
Views: 4243
Reputation: 71
In the above case the expandNodeId is the ID that you assigned to the node that was clicked. So, in your onClick() function you can do something like this;
var theTree = new Tree({
model: myModel,
onClick: function(item, node){
// auto-expand the node when clicked
var nodes = that.theTree.getNodesByItem(item.id);
if(!nodes[0].isExpanded)
theTree._expandNode(nodes[0]);
}
});
Upvotes: 0
Reputation: 257
If you have id of the node that you want to expand. you can expand that node as follows - myTree will be your tree and expandNodeId is the id of the node you want to expand.
var nodes = myTree.getNodesByItem(expandNodeId);
if(!nodes[0].isExpanded){
myTree._expandNode(nodes[0]);
}
Upvotes: 3