MzTreeView.prototype.expandAll = function()
{
  if(this.totalNode>500) if(
    confirm("您是否要停止展开全部节点?\r\n\r\n节点过多!展开很耗时")) return;
  if(this.node["0"].childNodes.length==0) return;
  var e = this.node["0"].childNodes[0];
  var isdo = t = false;
  while(e.id != "0")
  {
    var p = this.node[e.parentId].childNodes, pn = p.length;
    if(p[pn-1].id==e.id && (isdo || !e.hasChild)){e=this.node[e.parentId]; isdo = true;}
    else
    {
      if(e.hasChild && !isdo)
      {
        this.expand(e.id, true), t = false;
        for(var i=0; i<e.childNodes.length; i++)
        {
          if(e.childNodes[i].hasChild){e = e.childNodes[i]; t = true; break;}
        }
        if(!t) isdo = true;
      }
      else
      {
        isdo = false;
        for(var i=0; i<pn; i++)
        {
          if(p[i].id==e.id) {e = p[i+1]; break;}
        }
      }
    }
  }
};
这是全部展开,我能不能传个什么值进来,只展个这个节点下面的所有子节点

解决方案 »

  1.   

    没用过,只是根椐现有的代码猜的,LZ试试...  
    MzTreeView.prototype.expandAll = function(index) {
        if(this.totalNode>500) {
            if(confirm("您是否要停止展开全部节点?\r\n\r\n节点过多!展开很耗时")) return;
        }
        if(this.node[index].childNodes.length==0) return;
        var e = this.node[index].childNodes[0];
        var isdo = t = false;
        while(e.id != index) {
            .....
        } 
    }