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

Drag&Drop cannot work under the column sorting

1 Answer 50 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kun
Top achievements
Rank 2
Kun asked on 11 Mar 2019, 03:37 PM

Hello,

My gridview is in bound mode. I reorder the rows by drag & drop. I'm inspired by this telerik github demo:

https://github.com/telerik/winforms-sdk/tree/master/GridView/BoundGridReorderRows/GridViewRowsReorderBoundModeVB

I change the order of data source in order to reorder the rows by drag & drop. It worked well.

But if a column is sorted, any drag & drop cannot be toke into account. And then if I canceled a column sorting, the order synchronize well by drag & drop.

I wonder the column sorting maybe changed the order of child rows, not the order of rows, but then I change the order of rows (data source) by drag & drop, the order of child rows stays put strangely. So that's why there is no reordering affecting the display.

What happens between child rows and rows when I cancel the column sorting ?

What is the way out of this situation?  I would like drag & drop has higher priority than column sorting/grouping.

 

Thank you by advance.

 

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Mar 2019, 10:55 AM
Hello, Kun,    

RadGridView exposes two collections that contain data rows:
- Rows - contains all data rows that belong to RadGridView. Data operations such as grouping, sorting, filtering, etc. do not change the content of the collection or the order in which the row objects exist in the collection.
- ChildRows - returns the data rows that are currently represented by RadGridView in the order in which they appear. The collection is modified every time a data operation (grouping, sorting, filtering) occurs.

When you sort a certain column, the rows appear according to the applied SortDescriptor. The drag and drop behavior doesn't affect this order. This is desired behavior. 

However, RadGridView supports custom sorting functionality which allows you to implement your own custom logic for the sort order. A sample idea is to use a separate column for the order index. Thus, you can use this field for the custom sorting logic and determine the sort order. Then, when you reorder the rows, you can manipulate the order index and thus control the sorting as well. Additional information about the custom sorting behavior and how to use its API is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/sorting/custom-sorting

Feel free to use a similar approach for achieving the custom requirement that you have.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
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
Kun
Top achievements
Rank 2
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or