dhtmlxTree目录树增加右键菜单以及拖拽排序的实现(2)

tree.setDragHandler(function(id,id2){//id为拖拽目录的ID,id2拖拽终点目录。将id2做为id的父目录。
    //art.dialog.confirm("Do you want to move node " + tree.getItemText(id) + " to item " + tree.getItemText(id2) + "?",function(){
      $.post("tree/move_folder.php",{id1:id,id2:id2},function(tips){
          //art.dialog.through({title:'信息',icon:'face-smile',lock:true,content:tips,ok:function(){art.dialog.close();location.reload();}});
      });
      return true;
    //});
  });
  //tree.setXMLAutoLoading("./tree/get.php");
  tree.loadXML("./tree/get.php");
  setTimeout('a()',500);
});

function a(){//绑定右键菜单。
    $('#treeboxbox_tree span').contextMenu('jqueryDtreeMenu',{
    onContextMenu: function(e) {
      if(1){
          return true;
      }else return false;
    },
    bindings: {
      'new':function(t){
        id=$(t).attr("name");
        id=parseInt(id);
        if(id==-1){
          title='创建目录';
        }else{
          title='在“'+$(t).html()+'”目录下 创建';
        }
        art.dialog.open(global_current_folder+'tree/edit_folder.php?do=create&t_folder_id='+id,{id:'edit',title:title,lock:true,height:'60px',resize:false},false);
      },
      'modify':function(t){
        id=$(t).attr("name");
        //“我的文档”中,是以当前用户的“用户名”为根目录的。比如员工的登陆帐号为:郑明,则“我的文档”中,以“郑明”为根目录做为起点。该名称不可更改。增加对$parentId的判断,就是避免给用户造成错觉。
        if(id==-1){
          showMsg(0,'提示','face-smile','该名称不可修改');
          return false;
        }else{
          var name=$(t).html();
          name=encodeURIComponent(encodeURIComponent(name));
          art.dialog.open(global_current_folder+'tree/edit_folder.php?do=modity&name='+name+'&t_folder_id='+id,{id:'edit',title:'修改目录',lock:true,height:'60px',resize:false},false);
        }
      },
      'delete':function(t){
        id=$(t).attr("name");
        if(id==-1){
          showMsg(0,'提示','face-smile','该目录不可删除');
          return false;
        }else{
          var name=$(t).html();
          art.dialog.confirm('确认删除“'+name+'”目录吗?',function(){
           $.post("tree/del_folder.php",{id:id},function(tips){
              art.dialog.through({title:'信息',icon:'face-smile',lock:true,content:tips,ok:function(){art.dialog.close();location.reload();}
              });
            });
            return true;
          });
        }
      },
      'refresh': function(t) {
        location.reload();
      }
    }
  });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/215e8ca140cb0a62877f60f3bdcf773c.html