Hi Manoj,
For the user to be able to click on a column header in the table and that result in forcing the order of the GROUPS could be done by
listening to the ''SortedColumns changed'' event of the ''TableDescriptor of GridGroupingControl.
Here is the steps and code snippet to acheive this behavior:
step 1) Define handlers for the SortedColumns.Changed event in the Page_Init
this.GridGroupingControl1.TableDescriptor.SortedColumns.Changed += new
Syncfusion.Collections.ListPropertyChangedEventHandler(this.GridGroupingControl1_SortedColumnsChanged);
step 2) Inside the GridGroupingControl1_SortedColumnsChanged Event check for the name of the sorted column
//Retreive the name of the sorted column
SortColumnDescriptor scd = (SortColumnDescriptor)e.Item;
sortedcolumns = scd.Name;
step 3) Check for the Action performed inside this event, here check for these 2 cases "Add" and "ItemPropertyChanged", Where the case
"Add" gets called only for the first time and ''ItemPropertChanged'' there after a columns sorted direction is changed.
step 4)Based on the sorted columns direction you can change the sorting order of the group as follows
//forcing the first gridgroupedColumn''s sort direction to ascending.
this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Ascending;
[Sample code in c#]
private void GridGroupingControl1_SortedColumnsChanged(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
string sortedcolumns;
SortColumnDescriptor scd = (SortColumnDescriptor)e.Item;
sortedcolumns = scd.Name;
if (scd.Name == "sortedcolumn") // consider the sorted columns name is ''sortedcolumn''
{
switch (e.Action)
{
case ListPropertyChangedType.Add:
case ListPropertyChangedType.ItemPropertyChanged:
{
//Check for the ''sortedcolumns'' direction and force the groups to be sorted based on this.
if (scd.SortDirection == ListSortDirection.Ascending)
{
this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Ascending;
//You can also do by checking the name of the group to get the name of the group the code is as follows
//this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].Name retreives the name of the group
}
else if (scd.SortDirection == ListSortDirection.Descending)
{
this.GridGroupingControl1.TableDescriptor.GridGroupedColumns[0].SortDirection = ListSortDirection.Descending;
}
break;
}
}
}
}
Also attached the sample illustrating this
Click here to download the Sample
Best Regards,
A.Sivakumar.