Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
345
SortedColumn -Remove automatic sorting
posted

We have an ultrwingrid with a sorted column named Category. (Please see the attachment)  We have Up/Down functionality to move UltragridGroupByrow) up/down.

We are using ultragrid.row.move to facilitate up/down functionality

The problem we are facing is after moving a group row up/down if rebind the grid it’s getting sorted based on sorted column automatically, and the groupByrows are restoring the initial position.

 Is there a way to stop the automatic sorting of sorted column? Or do we have any provision to group based on a column, without using Sorted column method

 

  • 469350
    Offline posted

    This will be very tricky. There's really no way for the grid to keep track of the rows that were moved once you re-bind the grid. When you re-bind, all of the existing grid rows are destroyed and a whole new set of rows are created for the new data in the new data source. There's no way for the grid to associate a row in the old data source with a row in the new one.

    So the only way to do this would be for you to add a field to your data source that keeps track of the order of the rows and then use a SortComparer on whatever field you are grouping by which takes the new field into account.

  • 69832
    Offline posted

    When you sort a column, it changes the row positions, so this is going to interfere with your attempts to move rows to specific locations. You can, however, assign a custom IComparer implementation to the column's SortComparer property, which takes into account whether the row has been explicitly positioned. You would have to do something like keep track of the position for rows on which you called the Move method, and then handle them differently in the sort comparer.