Specify callback function to be called before drag-drop of a node, The return value controls the execution of drag-drop callback.
Default: null
When a node is dropped, if the drop is not in a valid location, this callback will not be triggered, and will revert to the original position.
zTree unique identifier: treeId, the id of the containing tree.
A collection of the nodes which has been dragged
The treeNodes which have been dragged, when copying nodes or moving nodes.
JSON data object of the destination node on which treeNodes are being dropped.
If the treeNodes is the root node, the targetNode = null
the relative position of move to the target node
"inner": will be child of targetNode
"prev": will be sibling node, and be in front of targetNode
"next": will be sibling node, and be behind targetNode
the flag used to determine if the drop is to copy or move the node
true: copy node; false: move node
return true or false
If return false, zTree will restore the dragged nodes, and will not trigger the 'onDrop' callback.
function myBeforeDrop(treeId, treeNodes, targetNode, moveType) {
return !(targetNode == null || (moveType != "inner" && !targetNode.parentTId));
};
var setting = {
edit: {
enable: true
},
callback: {
beforeDrop: myBeforeDrop
}
};
......