javascriptdojodijit.tree

expand particular node in dojo tree


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.


Solution

  • 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]);
    }