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

DragDrop between GridView and child GridView in HierachyChildTemplate

1 Answer 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 12 Mar 2019, 12:22 PM

Hi,

I am developing a control which contains a GridView. Some of the items can have sub items which are assigned to another GridView which is the HierarchyChildTemplate of the main GridView.
How can I implement a drag and drop functionality between the main GridView and the child GridView and vice versa.

 

Thanks.

 

Best regards

Peter

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 14 Mar 2019, 09:42 AM
Hello Peter,

May I ask you to check out the Reorder Rows and the Tree To Grid Drag RadGridView examples from our demos. Please, note that we do not have an example demonstrating drag&drop between a child and parent grid, however I will try to explain how you can achieve that.

Basically the scenario with hierarchical grids is a hybrid one, between the reorder logic and a drag between controls logic. Overall the idea and main difference between the two actions is that when you drag on the same level, you modify one collection. Remove the item from it and insert it in the correct index location. When dragging on different levels, you have to remove the item from the source grid and insert it in the correct index in the target grid. 

In order to distinguish between the parent and child grid, you can use the Drop and DragOver events to obtain the target GridViewRow:
var row = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();

You can then use the GridViewDataControl property of the row to determine the RadGridView that it belongs to. 

I hope you find this helpful. Let me know if I can be of any further assistance. 

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or