ztree|ztree 拖拽

ztree|ztree 拖拽
文章图片

一定要引入jquery.ztree.exedit.js文件,不然根本不会触发onDrag事件!!!!!
其他的官网上有例子就不说了
【ztree|ztree 拖拽】将节点拖拽到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 ; .... }

    推荐阅读