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. Image for the cookie policy date
close icon

Alternate way to group on SFDataGrid

Are there any alternate ways to perform grouping on a given data column ?
at this point the control seems to support dragging and dripping a column on to a Group Drop area, but are there any other ways to implement grouping ?
like clicking a button inside the column ? or by right clicking on the column and grouping them ?
Can you please provide me with some examples ?


thanks 

1 Reply

JN Jayaleshwari N Syncfusion Team February 5, 2019 08:50 AM UTC

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. 


Loader.
Live Chat Icon For mobile
Up arrow icon