Drag and Drop within a group of a RadGridView

1 Answer 23 Views
DragAndDrop GridView
Carlo
Top achievements
Rank 1
Iron
Carlo asked on 14 Jan 2025, 06:58 PM | edited on 14 Jan 2025, 07:13 PM

Hi there, 

I implemented a drag and drop behavior within a radgridview based on this page: https://docs.telerik.com/devtools/wpf/controls/dragdropmanager/how-to/howto-draganddrop-within-radgridview and it works correctly.

But now I need to introduce grouping of elements based on a specific property

<telerik:RadGridView.GroupDescriptors>
	<telerik:GroupDescriptor Member="GroupingField" SortDirection="Ascending" />
</telerik:RadGridView.GroupDescriptors>

I was able to modify the RadGridViewRowDragDropBehavior class so that dragging is limited to the current group, but when it is allowed, the dragged element falls to the last position in the group instead of the desired position. For example:

Group A
    Item 1
    Item 2
Group B
   Item 3
   Item 4
   Item 5
   Item 6
Group C
   Item 7

when I drag “item 3” and drop it after “item 4” the result is as follows: 

Group B
   Item 4
   Item 5
   Item 6
   Item 3

I tied to solve the problem by invoking the RadGridView.Rebind() method at the end of RadGridViewRowDragDropBehavior.OnDrop, but it does not work and I don't think this is the best solution, any suggestions?

Thanks

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Carlo
Top achievements
Rank 1
Iron
answered on 14 Jan 2025, 07:46 PM
the problem was related to the fact that, during grouping, moving an element within the collection used inconsistent indexes
Tags
DragAndDrop GridView
Asked by
Carlo
Top achievements
Rank 1
Iron
Answers by
Carlo
Top achievements
Rank 1
Iron
Share this question
or