ztree 拖拽

作者: 啊啊啊阿南 | 来源:发表于2018-08-08 17:03 被阅读0次

    一定要引入jquery.ztree.exedit.js文件,不然根本不会触发onDrag事件!!!!!
    其他的官网上有例子就不说了

    将节点拖拽到handsontable表中

    var setting = {             
     data: {                  
      simpleData: {                   
       enable: true,                  
      },                 
      view: {               
       showLine: true           
      },                
    },
    edit: {
     enable: true,
     showRemoveBtn: false,                  
     showRenameBtn: false,                  
     drag:{                     
      isCopy: false,                        
      prev: false,                  
      next: false,                  
      inner: false              
     }          
    },          
    callback: {                 
     //拖拽时鼠标放开事件                
     onDrop: treeOnDrop,
     }
    };
    function treeOnDrop(event, treeId, node, targetNode, moveType) {          
     var dragObj = {};        
     var $destination = $(document.elementFromPoint(event.clientX, event.clientY));      
     var $tr = $destination.closest('tr');        
     var $tbody = $tr.closest('tbody');       
     var col = $tr.children().index($destination);        
     var row = $tbody.children().index($tr);
     //dragObj.row = row;         
     //dragObj.col = col - 1;   
    ....        
    }  
    
    //或者
    function treeOnDrop2(event, treeId, node, targetNode, moveType) {         
     var dragObj = {};        
     var row = event.target.cellIndex -1;
     var col =   event.target.parentNode.sectionRowIndex;
     //dragObj.row = row;         
     //dragObj.col = col ;  
    ....        
    }  
    
    

    相关文章

      网友评论

        本文标题:ztree 拖拽

        本文链接:https://www.haomeiwen.com/subject/ieexbftx.html