Home > Enterprise >  Get new parentId of row after drag and drop in ej2-treegrid
Get new parentId of row after drag and drop in ej2-treegrid

Time:09-16

I have a syncfusion treeGrid component with drag and drop activated. When a component is dropped I would like to know what row is gonna be the parent after the drop (what's the new parentId).

CodePudding user response:

Searching the documentation, you have these events that fire from drag and drop actions. Sounds like you want to listen to rowDrop event. This event will provide these event arguments, of which I think you want dropIndex property. With the index of the row dropped on you should be able to look up the id and other information in your rows data array.

CodePudding user response:

Query#:-When a component is dropped I would like to know what row is gonna be the parent after the drop (what's the new parentId).

From using getCurrentViewRecords method, we can get the ParentItem or ParentID of the dropped Child with Children property of that record and if it is dropped as Parent, ParentItem remains undefined. You can get the details from actionComplete event of the TreeGrid after rowDrag and drop operation.

Refer to the documentation lInk:- https://ej2.syncfusion.com/vue/documentation/api/treegrid/#getcurrentviewrecords https://ej2.syncfusion.com/vue/documentation/api/treegrid/#rowdrop

Screenshot: (while dropping TaskID 3 to taskID: 7) With Self-reference structure

(while using Hierarchical data)

Please get back to us if you need any further assistance.

Regards, Farveen sulthana T

  • Related