Drag&Drop cannot work under the column sorting

2 posts, 0 answers
  1. Kun
    Kun avatar
    44 posts
    Member since:
    Aug 2018

    Posted 11 Mar 2019 Link to this post


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


    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.



  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4004 posts

    Posted 12 Mar 2019 Link to this post

    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. 

    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.
Back to Top