0

the question is simple but I didn't found any similar to this. I'd like to enable fancytree with dnd plugin, but each node should maintain his own parent (if it's root he should remain root).

Thanks, Riccardo

riccardo.tasso
  • 978
  • 2
  • 10
  • 28

1 Answers1

0

This is the solution I was looking for:

extensions: ["dnd"],
dnd: {
    autoExpandMS: 400,
    focusOnClick: true,
    preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
    preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
    dragStart: function(node, data) {
        // if false dnd is disabled
        return true;
    },
    dragStop: function(node, data) {
        return true;
    },
    dragEnter: function(node, data) {
        if(node.parent !== data.otherNode.parent) return false;
        return true;
    },
    dragDrop: function(node, data) {
      // if dropped to another node insert it before!
      data.otherNode.moveTo(node, "before");
}
riccardo.tasso
  • 978
  • 2
  • 10
  • 28