Drag and Drop external Element -> Need better example
See original GitHub issueI am trying to drag and drop external elements into the tree.
I have defined my external element like so:
<span [treeDrag]="{displayName: item.displayName}" [treeDragEnabled]="true">{{item.displayName}}</span>
But I get an error when dropping the element
EXCEPTION: Error in ./CreateTemplateComponent class CreateTemplateComponent - inline template:66:14 caused by: node.getIndexInParent is not a function
The docs suggest to implement a custom handler, but how should this handler look like?
You specify the element that will be reported as ‘from’ in actionMapping (instead of the node when dragging a tree node).
Does this mean I need to create a new TreeNode, add it to the tree, update the view and then move the node, so the tree kind of handles it like an internal drop (and not external)? It’s extremely confusing for me, can someone clarify?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
The so called ‘updated docs’ haven’t provided any clue as to what needs to happen to drag an external element into the tree.
Can someone please provide a better example?
Hi,
I updated the docs.
You don’t need to create a new TreeNode. You need to update the original nodes structure and then call
tree.update()
on the tree.Checkout the new docs: https://angular2-tree.readme.io/v3.3.0/docs/drag-drop