FancyTree DnD how to allow only drop into valid folders and not outside of parent

125 Views Asked by At

I have a fancytree table which has A Main Folder A Child and a child of a child. below is what I would like to achieve

 Static(Folder) -> Not Droppable
   | 
   Cycles(Folder) -> Not Droppable
    |
    [0] -> (folder) -> Able to drop into
    ----------------------- Cannot Drop Nodes Here
    [1] -> (folder) -> Able to drop into
    ----------------------- Cannot Drop Nodes Here
    [2] -> (folder) -> Able to drop into

My current code sorta works, but I had to set a custom flag for the nodes called "droppable" and if its false then don't allow dragging into it. You can't drop into the folder itself, but if its expanded you're still able to drag into the folder at any position. I only want to allow the node to go into the folders that are valid.


dragEnter: function(node, data) {
                      
     if (node.data.droppable == false) {
         return false;
      }
        
      return true;
 },

0

There are 0 best solutions below