20
Views
1
Comments
Solved
[zTree] Allow Drag-Drop only at the current level
Question
ztree
Web icon
Forge asset by Eduardo Luís

Hello!

How do I not allow Drag-Drop to insert a node inside another node? Drag-Drop is only allowed at that level that the user is performing the Drag-Drop.


Thanks!

2022-06-17 09-22-26
Huarlem Lima
Solution

Hi Danilo,

To not allow dropping one node into the other, use the setting 'ztreeSettingsEdit.ztreeSettingsEdit.drag.ztreeSettingsEditDrag.inner' a false


To not allow dropping on another level, we can use the beforeDrop callback method.

here is the javascript;

function (treeId, treeNodes, targetNode, moveType) {
     
    var output = treeNodes[0].level== targetNode.level;
    if(!output){
        alert('You cannot drag to another level');
    }
return output;

See screenshot:

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.