How to clear grouping when long pressing on a caption row in .NET MAUI DataGrid (SfDataGrid)?
In the .NET MAUI DataGrid, you can clear the grouping by long-pressing on a caption row, achieved by clearing the SfDataGrid.GroupColumnDescriptions within the CellLongPress event.
Refer to the code example below, where the SfDataGrid
is grouped by a column, and the CellLongPress
event is hooked.
XAML:
<syncfusion:SfDataGrid x:Name="datagrid"
ColumnWidthMode="Auto"
ItemsSource="{Binding Employees}"
CellLongPress="SfDataGrid_CellLongPress">
<syncfusion:SfDataGrid.GroupColumnDescriptions>
<syncfusion:GroupColumnDescription ColumnName="Name">
</syncfusion:GroupColumnDescription>
</syncfusion:SfDataGrid.GroupColumnDescriptions>
</syncfusion:SfDataGrid>
C#:
private void SfDataGrid_CellLongPress(object sender, DataGridCellLongPressEventArgs e)
{
if (e.RowData is Group)
datagrid.GroupColumnDescriptions.Clear();
}
Download the complete sample from GitHub.
Conclusion
I hope you enjoyed learning how to clear grouping when long-pressing on a caption row in .NET MAUI DataGrid (SfDataGrid).
You can refer to our .NET MAUI DataGrid feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!