Grid Grouping (with a different sort??)

Hello,

I have a grid grouping control seen here:

http://screensnapr.com/u/uiepc4.png

I have the inner grouping set to the [TabName] column. However, our tabs have an internal sorting based on a number. Where "General" is 1 and "Background Investigations" is 2. I need to be able to group by the [TabName] but sort the order by the [TabSort] so that "General" comes before "Background Investigations".

Or, another solution would be to group by [TabSort] but convert the display to show [TabName]. I tried going this route but it is difficult as the QueryCellStyle method already had the [TabSort] CellValue set to a RichText formatted string (since it was converted to show Bold)...

How can I achieve this?

4 Replies

JJ Jisha Joy Syncfusion Team July 27, 2010 07:17 AM UTC

Hi Jeff,

When a column is grouped, then that column will be added to the sorted column collection. This is a default behvior and we cannot avoid this. But you could make the "TabSort" column sorting when "TabName" column get grouped by handling GroupedColumns.Changing events.

Here is the code:


// in GroupedColumns_Changing event

if (e.Action == Syncfusion.Collections.ListPropertyChangedType.Add || e.Action == Syncfusion.Collections.ListPropertyChangedType.Insert)
{
SortColumnDescriptor scd = e.Item as SortColumnDescriptor;
scd.SortDirection = ListSortDirection.Descending;
if (scd != null && scd.Name == "TabName")
{
this.grid.TableDescriptor.SortedColumns.Add("TabSort");
}
}

Regards,
Jisha


JV Jeff Voigt July 27, 2010 02:35 PM UTC

Well that did not change the end result. The General tab is still showing up on the bottom.


JV Jeff Voigt July 27, 2010 02:38 PM UTC

To be more specific, you mentioned that when you group a column it is added to the SortedColumns collection. That is not happening. If it look at the state after I group the columns the GroupedColumns collection has values while the SortedColumns collection is still empty. If I manually try to add the TabID to the sorted columns it does nothing.


JJ Jisha Joy Syncfusion Team July 30, 2010 08:43 AM UTC

Hi Jeff,

Thank you for your update. Could you please provide ua a sample showing the issue?. So that we could sort out the cause of the issue and provide youa solution based on it.

Regards,
Jisha

Loader.
Up arrow icon