一定要引入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 ; .... }
作者:啊啊啊阿南
链接:https://www.jianshu.com/p/2a6c2f41c3ca