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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to avoid selection while grouping and ungrouping in SfDataGrid?

Platform: UWP |
Control: SfDataGrid |
Published Date: January 25, 2016 |
Last Revised Date: September 29, 2016 |
.NET Framework: 4.5 |
Product Version:

In SfDataGrid, the selection is maintained based on SfDataGrid.SelectedItems when grouping and ungrouping. If SelectedItems is zero, then the SfDataGrid processes selection behavior as follows:

  1. While grouping, the first caption summary row is selected and also if the Groups are collapsed, then the first caption summary row is selected by clearing SelectedItems.
  2. While ungrouping, first record row is selected.

Note: This is applicable only when SfDataGrid.SelectionUnit is Row.

If there are no SelectedItems, you can avoid the above default selection behavior by overriding the GridSelectionController, when SfDataGrid.SelectionUnit is Row. If SelectionUnit is Cell or Any, then you can override GridCellSelectionController, that handles all the selection operations in SfDataGrid.

You can set the customized GridSelectionController, GridSelectionControllerExt as per the above code snippet, to SfDataGrid.SelectionController property, as shown in the following code snippet.

GridSelectionController class has various virtual methods that are called for different actions. To handle the selection while grouping or ungrouping, you have to override ProcessOnGroupChanged method in your SelectionController, as shown in the following code snippet.


In the above code, the ProcessOnGroupChanged method is called while grouping or ungrouping a column in SfDataGrid. RefreshSelectedItems method removes the items that are not displayed in the View. Because, while grouping, if the groups are not expanded, the SelectedItems will be cleared and the first caption summary is selected by default. The UpdateCurrentRowIndex method updates CurrentCell based on CurrentItem.


Figure 1: While grouping, the first caption summary row is selected

Figure 2: Avoid selection while grouping and ungrouping in SfDataGrid

Sample Links







2X faster development

The ultimate UWP UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon