Angular-tree-component: Is there a way to limit the number of levels deep an item can be dragged?

Created on 1 Nov 2016  路  5Comments  路  Source: CirclonGroup/angular-tree-component

Hey there, I noticed there is a ton of really nice functionality with this component, but I was wondering...is there a way to limit the number of nested levels from root that can set as a config option?

Thanks!

Most helpful comment

Sorry there is a way to do this by overriding actionMapping.mouse.drop action.

then move the node only in certain conditions. Something like this:

actionMapping: {
  mouse: {
    drop: (tree:TreeModel, node:TreeNode, $event:any, to:{ node:TreeNode, index: number }) => {
      if (node.level < X) {
        TREE_ACTIONS.MOVE_NODE(tree, node, $event, to);
     }
     else {
        alert('cannot drop here');
     }
    }
  }
}

Please try and let me know

All 5 comments

Hi.
Currently there isn't a way, but I might refactor the drag and drop and add this option in the coming weeks.
I will update this thread

Sorry there is a way to do this by overriding actionMapping.mouse.drop action.

then move the node only in certain conditions. Something like this:

actionMapping: {
  mouse: {
    drop: (tree:TreeModel, node:TreeNode, $event:any, to:{ node:TreeNode, index: number }) => {
      if (node.level < X) {
        TREE_ACTIONS.MOVE_NODE(tree, node, $event, to);
     }
     else {
        alert('cannot drop here');
     }
    }
  }
}

Please try and let me know

Hey @adamkleingit, Sorry it's taken me so long to respond to your response, but I did try out what you suggested and it's doing exactly what I want it to. Thankyou so much :)

Sorry there is a way to do this by overriding actionMapping.mouse.drop action.

then move the node only in certain conditions. Something like this:

actionMapping: {
  mouse: {
    drop: (tree:TreeModel, node:TreeNode, $event:any, to:{ node:TreeNode, index: number }) => {
      if (node.level < X) {
        TREE_ACTIONS.MOVE_NODE(tree, node, $event, to);
     }
     else {
        alert('cannot drop here');
     }
    }
  }
}

Please try and let me know

it's doing exactly what I want it to !!!!!!!! thank you!!!!!!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vishnusangam picture Vishnusangam  路  4Comments

anoop-chauhan picture anoop-chauhan  路  3Comments

matthewdfleming picture matthewdfleming  路  3Comments

hipresario picture hipresario  路  4Comments

filipemansano picture filipemansano  路  5Comments