遍历所有节点 ,打开的设置关闭,打开点击的节点。或用cookie记录打开的节点,点开另一个节点,先关闭cookie记录的节点。

解决方案 »

  1.   


    MzTreeView.prototype.newExpand = function (id)
    {
    var currentNode = this.node[id];
    if (!currentNode.hasChild||currentNode.isExpand)
    {
    this.expand(id);
    return;
    }
    var childNodes = currentNode.parentNode.childNodes;
    for (var index in childNodes)
    {
    if (childNodes[index]==currentNode)
    this.expand(id,true);
    else
    this.expand(childNodes[index].id,false);
    }
    }
      

  2.   

    增加上面那个函数
    修改MzTreeView.prototype.clickHandle为//树的单击事件处理函数
    MzTreeView.prototype.clickHandle = function(e)
    {
      e = window.event || e; e = e.srcElement || e.target;
      //alert(e.tagName)
      switch(e.tagName)
      {
        case "IMG" :
          if(e.id)
          {
     /*
            if(e.id.indexOf(this.name +"_icon_")==0)
              this.focusClientNode(e.id.substr(e.id.lastIndexOf("_") + 1));
            else if (e.id.indexOf(this.name +"_expand_")==0)
              this.newExpand(e.id.substr(e.id.lastIndexOf("_") + 1));
      */
      this.focusClientNode(e.id.substr(e.id.lastIndexOf("_") + 1));
         this.newExpand(e.id.substr(e.id.lastIndexOf("_") + 1));
          }
          break;
        case "A" :
          if(e.id) this.focusClientNode(e.id.substr(e.id.lastIndexOf("_") + 1));
      this.newExpand(e.id.substr(e.id.lastIndexOf("_") + 1));
          break;
        case "SPAN" :
          if(e.className=="pm")
            this.newExpand(e.id.substr(e.id.lastIndexOf("_") + 1));
          break;
        default :
          if(this.navigator=="netscape") e = e.parentNode;
          if(e.tagName=="SPAN" && e.className=="pm")
            this.newExpand(e.id.substr(e.id.lastIndexOf("_") + 1));
          break;
      }
    };
      

  3.   

    谢谢各位帮助,尤其谢谢littlelam大哥,麻烦您给我发一下吧,我是新手,不太熟,好好研究一下代码!.cn或者[email protected],麻烦您了,我先用您发的上面的这个试试
      

  4.   

    littlelam大哥,上面发的代码不太灵啊,点开哪个不展开哪个啊,麻烦再指点一下咯