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
415
How to prevent sorting when group by column?
posted

Hi all,

When we group by column, the Grid will do 2 functions:

1. Sort on the column which we want to group by

2. Execute grouping

So my question is: How do we prevent the step 1 and provide new datasource for Grid to Grouping?

For example: When we group by column, the Grid will do as below:

1. Stop the sorting on the column which we want to group by

2. Get the data from our Database (already sorted on that column) and bind to Grid

3. Grid will group with datasource which we get from step 2

Can I do that?

Thanks a lot for helping,

Dan

PS: sorry if it duplicate with another thread because I can not search any thread similar with my issue.

 

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Dan,

    You can't. The way grouping works is that the grid sorts the data and then loops through rows to find matching, adjacent values in order to group them. The data has to be sorted in order to be group.

    You could add a SortComparer to the column which does nothing, but then when you grouped the data, only rows that already happened to have the same value and are adjacent would get grouped, which means you could end up with two or more groups for the same value. So I guess this would work if the data in the grid were already sorted.

Children