- Home
- Forum
- Angular - EJ 2
- New parent ID of dragged item
New parent ID of dragged item
I’m struggling to get the appropriate id# for the new parent of an item I drag and drop in a TreeGrid so I can write it to the database. My results have been inconsistent.
Given this:
ID Name
1 Item A
2 Item B
3 Item C
If I drop #3 item C onto #1 Item A to give this:
1 Item A
3 Item C
2 Item B
I need to see that #1 is the parent of the item I dropped (#3)
If I then drop #3onto #2 to give this:
1 Item A
2 Item B
3 Item C
I need to see that #2 is the parent of the item I dropped (#3)
Then if I return #3 to ‘root’
1 Item A
2 Item B
3 Item C
I need to see the parent of item #3 is null
The dragged item is fine via:
rowDrop(args: any ) {
//let x = args;
var droppedID = args.data[0].id; //this is ok. item we dragged
var treeGridobj = (document.getElementById('treegridReq') as any).ej2_instances[0];
var data = treeGridobj.getCurrentViewRecords()[args.dropIndex];
But the new parent is yielding odd results which indicates I’m not doing it correctly.
Please help me sort this one out.
Cheers- Complete TreeGrid code details.
- Video Demo/ Screenshot to replicate the issue.
- If possible replicate it in the above sample and share Screenshots accordingly.
- Share detailed Explanation of your requirement.
My problem really was getting the data from what I dropped it onto. But you helped get me there with a little more fiddling.
Thanks
- 3 Replies
- 2 Participants
-
WC Walter Cook
- Sep 21, 2021 05:45 PM UTC
- Sep 24, 2021 03:47 PM UTC