This is a migrated thread and some comments may be shown as answers.

Drag and Drop Target Grid

1 Answer 13 Views
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Veteran
Claude asked on 29 Dec 2020, 10:33 PM

I have it mostly working but am having one issue.  I am trying to get the rowinfo in the target grid where the files are dropped.   Grid 1 has a one to many relationship to grid 2.  I am trying to drag data from grid 2 to a different in row in Grid 1.  I want to get the serialID field of the target row in Grid 1, but have not been able to find a way to get that info. 

 

Thank you as always.

1 Answer, 1 is accepted

Sort by
0
Nadya
Telerik team
answered on 30 Dec 2020, 01:34 PM

Hello, Claude,

It is not clear how exactly you set up the drag-drop functionality, but I suppose that you use the build-in RadGridViewDragDropService which handles the whole drag and drop operation in RadGridView

The PreviewDragOver event allows you to control on what targets the row being dragged can be dropped on. The PreviewDragDrop event allows you to get a handle on all the aspects of the drag and drop operation, the source (drag) grid, the destination (target) control, as well as the row being dragged. It is possible to get the target row and extract its cells' values while dragging over. In PreviewDragOver you have access to the GridDataRowElement. Through the RowInfo property you can get the GridViewRowInfo:

 private void svc_PreviewDragOver(object sender, RadDragOverEventArgs e)
 {
     if (e.DragInstance is GridDataRowElement)
     {
         e.CanDrop = e.HitTarget is GridDataRowElement ||
                     e.HitTarget is GridTableElement ||
                     e.HitTarget is GridSummaryRowElement;
         GridDataRowElement targetRow = e.HitTarget as GridDataRowElement;
         if (targetRow != null)
         {
           GridViewRowInfo rowInfo = targetRow.RowInfo;
           // TO DO
         }
     }
 }

I hope this helps. Should you have other questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Claude
Top achievements
Rank 1
Veteran
Answers by
Nadya
Telerik team
Share this question
or