We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Sorting of grouped columns

Is it possible to sort the groups of a grouping grid by a different column than the one displayed for the groups? Specifically, I have a grouped column with the values Jan, Feb, Mar, ... and I want to sort the groups by date rather than alphabetically.

5 Replies

AD Administrator Syncfusion Team May 19, 2005 11:43 PM UTC

One way you can do something like this is to use a custom comparer. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GGC_SortGroup_e105e8e1.zip


AD Administrator Syncfusion Team May 24, 2005 03:02 PM UTC

This works fine when setting the group order from code. However, if the user groups with another column and then regroups by the special column, the special order is lost. How can I handle this? I also have the same problem when using a custom comparer for a sorted column. If the user sorts by another column and then resorts by the special column, the custom comparer is not used anymore.


AD Administrator Syncfusion Team May 24, 2005 05:15 PM UTC

You have to handle a couple of events to dynamically create the comparer immediately before the sorting or the grouping. Here is the sample modified to do this. http://www.syncfusion.com/Support/user/uploads/GGC_SortGroup_50d39b20.zip


AD Administrator Syncfusion Team June 2, 2005 12:50 PM UTC

My compare operation is relatively expensive (requires a lookup in a separate table). With the custom comparer I guess this will be done on the order of n log(n) times. On the other hand, if I could simply change the sort column, I whould only need to initialize this new sort column once. This would require only n lookups and should thus be much cheaper than using the custom comparer. For the sorting it is easy to change the sort column, but I havn''t found a way to do this for the grouping. Is it possible in any way to change the sort column for the grouping? (I can of course create the new sort column and lookup that column from the custom comparer. Unfourtunately, the parameters provided to the comparer are the object values to compare rather than a reference to the records. Thus, I would still need a lookup in the table to find the records being compared, and this would be equally expensive.)


AD Administrator Syncfusion Team June 2, 2005 01:43 PM UTC

>>Is it possible in any way to change the sort column for the grouping The only way I know would through a custom comparer. Instead of doing the time consuming work in the custom comparer, can you do the work once in say the constructor for the comparer save the results of this work in some efficient datastucture (hashtable or orderlist), and then just have teh Comparer method look up teh value instead of doing the work? I think this would be ''essentially'' adding another column and doing the sort on this other column.

Loader.
Live Chat Icon For mobile
Up arrow icon