Limiting tree depth

73 views
Skip to first unread message

al...@alexhoward.com.au

unread,
Mar 20, 2018, 8:52:24 AM3/20/18
to Fancytree Q&A
Is there a straightforward or canonical method for limiting tree depth when using the DND extension?

al...@alexhoward.com.au

unread,
Mar 20, 2018, 2:08:02 PM3/20/18
to Fancytree Q&A
Well, in the end, I only wanted to allow my users to have two levels so I did this.

dragDrop: function(node, data) {
if (data.node.parent.parent == null) {
data.otherNode.moveTo(node, data.hitMode);
}
else {
//it wont add, send a message to the user
}
}

This works for me.

mar10

unread,
Mar 21, 2018, 3:14:31 AM3/21/18
to Fancytree Q&A
You can also restrict the list of allowed hit modes to prevent creating a child:

dragEnter: function (node, data) {
 
if  (node.getLevel() > 1 ) {
   
// Don't allow dropping *over* a node (would create a child). Just
   
// allow changing the order:
   
return ["before", "after"];
 
}
 
// Accept everything:
 
return true;
},



Reply all
Reply to author
Forward
0 new messages