The SfDataGrid provides support to freeze the rows and columns like Excel’s . By default, the filtering feature allows you to filter the data in the rows based on particular criteria. Initially, the Filter Popup is loaded with the FilterElements and the value of the FilterElements is the display value of the corresponding column. Once you filter, the FilterElements are reset based on the specified conditions. It does not have any special option to skip freezing the row data on filtering.
The following screenshot illustrates how the Filter Popup is loaded with its FilterElements when the FrozenRowsCount is defined in the SfDataGrid.
Figure 1: Default view of frozen rows in Filtering
In the SfDataGrid, it is possible to skip the frozen row data and maintain these frozen rows in view of the SfDataGrid on filtering. This can be achieved by using the FilterItemsPopulated and FilterChangingEvent events of the SfDataGrid.
These events are wired as shown in the following code example.
The FilterItemsPopulated event is raised when the filter item list is populated and the ItemsSource of the GridFilterControl is set. With the help of this event, you can manage filter values and avoid frozen row data being populated into the filter item list as shown in the following code example.
From the above code, you can get the filter values collection from the e.ItemSource argument of the GridFilterItemsPopulatedEventArgs class. To get the frozen rows count, use the FrozenRowsCount property of the SfDataGrid. Then remove those frozen rows from the e.ItemSource collection. This is represented in the following screenshot.
Figure 2: Frozen row data removed from Filter values
Retain the frozen row data in view by using the FilterChanging event of the SfDataGrid and that is used to manage the FilterPredicates collection. In the code, the frozen row data is added to the filter predicates by using the e.FilterPredicates argument.
The following screenshot illustrates that after filtering, the frozen row data is retained in view of the SfDataGrid:
Figure 3: Frozen row data retained in view after applied Filtering
This page will automatically be redirected to the sign-in page in 10 seconds.