7
Views
1
Comments
Solved
[zTree] Allow Drag-Drop only at the current level
Question
Forge component by Eduardo Luís
20
Published on 03 Oct 2019

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!

Rank: #68
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: