)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I change/reset the styles of sorted columns in a GridGrouping control?

Platform: ASP.NET Web Forms (Classic) |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: August 21, 2019

This can be done by handling the "GridGroupingControl.TableDescriptor.SortedColumns.Changed" event.This event is fired for both sorting and unsorting the columns.

In SortedColumnsChanged event, you can get the SortedColumns name and the performed action(sorted/unsorted). then you can change the styles of sorted columns and reset the styles of the Unsortedcolumns styles to its original state based on some criteria.

The following code sample shows how to set a back color of a sorted column.

C#

private void gridgroupingcontrol1_sortedcolumnschanged(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)

{

string sortedcolumns;

SortColumnDescriptor scd = (SortColumnDescriptor)e.Item;

sortedcolumns = scd.Name;

switch (e.Action)

{

case ListPropertyChangedType.Add:

{

this.GridGroupingControl1.TableDescriptor.Columns.FindByMappingName(sortedcolumns).Appearance.AnyRecordFieldCell.BackColor = Color.FromArgb(237, 240, 246);

break;

}

case ListPropertyChangedType.Remove:

{

this.GridGroupingControl1.TableDescriptor.Columns.FindByMappingName(sortedcolumns).Appearance.AnyRecordFieldCell.ResetBackColor();

break;

}

}

}

VB

     Private Sub GridGroupingControl1_SortedColumnsChanged(ByVal sender As Object, ByVal e As Syncfusion.Collections.ListPropertyChangedEventArgs)

         Dim sortedcolumns As String

         Dim scd As SortColumnDescriptor = CType(e.Item, SortColumnDescriptor)

sortedcolumns = scd.Name

         Select Case e.Action

Case ListPropertyChangedType.Add

Me.GridGroupingControl1.TableDescriptor.Columns.FindByMappingName(sortedcolumns).Appearance.AnyRecordFieldCell.BackColor = Color.FromArgb(237, 240, 246)

Exit Select

Case ListPropertyChangedType.Add

Me.GridGroupingControl1.TableDescriptor.Columns.FindByMappingName(sortedcolumns).Appearance.AnyRecordFieldCell.ResetBackColor()

Exit Select

         End Select

End Sub

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon