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
490
SortComparer ignored when Grouped?
posted

I have implemented an instance if IComparer and assigned it to the SortComparer property of a Column.   When I click on the Column header the SortComparer is only called if the data is not grouped.  If the data is grouped - the SortComparer is never called.

 How can I ensure that the SortComparer is invoked?

The core problem is how to sort groups and the rows within the group based upon the column header that is clicked.  I tried to use a GroupRowComparer but it doesn't work (probably because it doesn't sort the data in the grid I guess). 

  • 469350
    Verified Answer
    Offline posted

    I'm not sure I follow you. What's a GroupRowComparer? 

    The way grouping in the grid works is that the column you are grouping on is first sorted. So the actual data rows are sorted and this sort will use the SortComparer of the column if one is specified. 

    Then the grid loops through each row and looks to see if the row has the same value as the previous row and is therefore in the same group. 

    After this is done, the GroupByRows may also be sorted by using the GroupByRowSortComparer on the column. So this allows you to put the GroupByRows in an order that is not neccessarily the same as the sorted order of the data.