How to programatically obtain the Column name and Order of Sorting no matter on clicking the GridGroupingControl Columns?
To obtain the column name and order of sorting by clicking the column name when the GridControl is grouped by any of the column, the SortedItemsInGroup event can be used to obtain this. Please refer the below code snippet which illustrates this:
C#
this.GridGroupingControl1.SortedItemsInGroup += new GroupEventHandler(GridGroupingControl1_SortedItemsInGroup);
void GridGroupingControl1_SortedItemsInGroup(object sender, GroupEventArgs e)
{
SortColumnDescriptorCollection collection = e.Group.Details.ParentTableDescriptor.SortedColumns;
foreach (SortColumnDescriptor sort in collection)
{
//Get the name of Sorted Columns
this.TextBox1.Text +=" " + sort.GetName();
//Get the Direction
this.TextBox1.Text += " " + sort.SortDirection;
}
}
VB
AddHandler GridGroupingControl1.SortedItemsInGroup, AddressOf GridGroupingControl1_SortedItemsInGroup
Private Sub GridGroupingControl1_SortedItemsInGroup(ByVal sender As Object, ByVal e As GroupEventArgs)
Dim collection As SortColumnDescriptorCollection = e.Group.Details.ParentTableDescriptor.SortedColumns
For Each sort As SortColumnDescriptor In collection
'Get the name of Sorted Columns
Me.TextBox1.Text &= " " & sort.GetName()
'Get the Direction
Me.TextBox1.Text &= " " & sort.SortDirection
Next sort
End Sub
Sample:
http://help.syncfusion.com/support/samples/kb/Grid.Web/6.1.0.34/GGCSortGroup/SortGroup.zip