闲云

    一张白纸,总想写上点什么...
  博客园 :: 首页 :: 新随笔 ::  :: 订阅 订阅 :: 管理

dojo tree的折叠和展开

Posted on 2010-09-26 09:59 闲云 阅读(133) 评论(0) 编辑 收藏
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);
}
}