dojo tree的折叠和展开

function collapseAll(branches, myTree){
   if(branches == null){     
      if(myTree == null){
         myTree = dijit.byId('MenuTree');
      }
      
      branches = myTree.rootNode.getChildren();
   }
   var branch;
   for(var i = 0; i<branches.length; i+=1){
      branch = branches[i];       
      collapseAll(branch.getChildren(), myTree);
      myTree._collapseNode(branch);
   }
}

function expandAll(branches,myTree){
if(branches == null){     
   if(myTree == null){
      myTree = dijit.byId('MenuTree');
   }
   
   branches = myTree.rootNode.getChildren();
}
var branch;
for(var i = 0; i<branches.length; i+=1){
   branch = branches[i];       
   expandAll(branch.getChildren(), myTree);
   myTree._expandNode(branch);
}
}
原文地址:https://www.cnblogs.com/xianyun/p/1835310.html