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


3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team September 22, 2021 04:12 PM UTC

Hi Walter, 

Thanks for contacting Syncfusion Support. 

Query#:- But the new parent is yielding odd results which indicates I’m not doing it correctly. 
 
From your query we suspect that you need draggeddata from args.data doesn’t contain any other properties such as ParentItem and any other information as child of ID 2 or ID 1. By default we will get the dragged Item information using args.data so that it return all details. 

You can get the original data once it get updated from getCurrentViewRecords using actionComplete event of the TreeGrid. 

Refer to the Screenshot:- 
 


If your requirement is different from above or we misunderstood your query share us the following details. 

  1. Complete TreeGrid code details.
  2. Video Demo/ Screenshot to replicate the issue.
  3. If possible replicate it in the above sample and share Screenshots accordingly.
  4. Share detailed Explanation of your requirement.

Regards, 
Farveen sulthana T 




WC Walter Cook September 23, 2021 08:17 PM UTC

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




FS Farveen Sulthana Thameeztheen Basha Syncfusion Team September 24, 2021 03:47 PM UTC

Hi Walter, 

Thanks for your update. Please get back to us if you are facing any difficulties on this. We are happy to assist you. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon