I'm looking for a solution for Nebular Tree Grid drag and drop option for rearranging hierarchical table data.
Example for nested Nodes (in my case the hierarchy is a little bigger):
- 1 Chapter
- 1.1 Element
- 1.2 Element
- 2 Chapter
- 2.1 Element
My goal is to have a clear info about what Element is dragged and where its dropped. (under- upper- or on Element)
If i drag 2.1 Element between 1.1 Element and 1.2 Element i need the info
"2.1 Element must be placed after 1.1 Element"
Is that possible with Nebular Tree Grid?
What i found so far was https://stackblitz.com/edit/angular-cdk-nested-drag-drop-tree-structure?file=src%2Fapp%2Fapp.component.ts
But i still didnt get it to run with my Nebular Tree Grid so i hope there is some of you who already did this :)
If you are on Angular, which I assume because of using Nebular, check out this page about using Angular cdk drag and drop directives:
https://material.angular.io/cdk/drag-drop/overview
It plays well and fairly easy with Nebular Tree Grid, here is how code to add drag and drop to a
nbTreeGridlooks like:edit: Note the
[cdkDragData]on thetr. I use this in my controller to know which element is being dropped in place of which other. Since all we get from drop events are the current and previous index of the dragged item, we need to keep track of the current index of each row in the table. I couldn't find another way to get this info fromNbTreeGridDataSource. Here is some controller code to give you an idea