This example describes how to access filtered records from WinUI DataGrid.
In WinUI DataGrid (SfDataGrid), the records visible to the user were present in the SfDataGrid.View.Records property. When the filter is applied, the SfDataGrid.View.Records property can be used to get the filtered records. The FilterChanged event occurs whenever the filter is changed. Thus, by using this event, the filtered records can be accessed in DataGrid. The following code example demonstrates how to get the filtered records by the FilterChanged event.
this.dataGrid.FilterChanged += OnFilterChanged;
private void OnFilterChanged(object sender, Syncfusion.UI.Xaml.DataGrid.GridFilterEventArgs e)
{
var filteredResult = this.dataGrid.View.Records.Select(recordEntry => recordEntry.Data);
}
The records in SfDataGrid.View.Records are of type RecordEntry that contain the underlying data. Thus by taking the RecordEntry.Data, the filtered records can be accessed in the underlying type.
Take a moment to peruse the WinUI DataGrid - Filtering documentation, where you can find about filtering with code examples.
Visual Studio 2019 and above versions