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.
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.
Hi Mike,
I solved my issue :). I customized my code as below to solve my problem:
1. Override the header click action to HeaderClickAction.ExternalSortSingle
this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.ExternalSortSingle;
the setting will prevent default sorting on gids column when use click on
2. Catch the BeforeSortChange event and Bind to Grid a new dataset which already sorted
That will solve my issue.
Btw, thanks you a lot, Mike
chdisme said:Override the header click action to HeaderClickAction.ExternalSortSingle
Oh, that's an even better idea. :)