Hi PRASANNA,
Thanks for contacting Syncfusion Support.
We have checked the reported query “Alternate way to group on SFDataGrid” from our side. You can achieve your requirement by adding GroupColumnDescription to SfDataGrid in any action.
We have prepared sample to group the right clicked column in datagrid MouseRightButtonDown event.
You can refer the following user guide documentation to know about programmatic grouping in SfDataGrid.
Code snippet C#: Grouping done while right click on column header.
private void DataGrid_PreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
GridHeaderCellControl headerCellControl = this.FindDescendant(e.OriginalSource, typeof(GridHeaderCellControl)) as GridHeaderCellControl;
if(headerCellControl != null)
{
if (dataGrid.GroupColumnDescriptions.Any(o => o.ColumnName == headerCellControl.Column.MappingName))
return;
dataGrid.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = headerCellControl.Column.MappingName });
}
} |
We have attached the sample for your reference and you can download the same from the following location.
Please let us know if you would require further assistance.
Regards,
Jayaleshwari N.