Experience Seamless Excel-Like Filtering in WinUI DataGrid 
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (163).NET Core  (29).NET MAUI  (81)Angular  (81)ASP.NET  (50)ASP.NET Core  (79)ASP.NET MVC  (88)Azure  (38)Blazor  (160)DocIO  (23)Essential JS 2  (89)Essential Studio  (180)File Formats  (33)Flutter  (123)JavaScript  (190)Microsoft  (114)PDF  (68)React  (65)Succinctly series  (128)Syncfusion  (634)TypeScript  (32)Uno Platform  (3)UWP  (4)Vue  (40)Webinar  (35)Windows Forms  (59)WinUI  (56)WPF  (140)Xamarin  (157)XlsIO  (26)Other CategoriesBarcode  (5)BI  (29)Bold BI  (5)Build conference  (6)Business intelligence  (54)Button  (4)C#  (121)Chart  (59)Cloud  (13)Company  (445)Dashboard  (8)Data Science  (3)Data Validation  (6)DataGrid  (56)Development  (418)Doc  (7)DockingManager  (1)eBook  (96)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (24)Extensions  (19)File Manager  (4)Gantt  (14)Gauge  (11)Git  (4)Grid  (28)HTML  (12)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (333)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (33)Performance  (10)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (8)Road Map  (11)Scheduler  (39)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (23)Solution Services  (3)Spreadsheet  (11)SQL  (8)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (95)UI  (238)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (23)Visual Studio Code  (17)Web  (396)What's new  (229)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Experience Seamless Excel-Like Filtering in WinUI DataGrid

Experience Seamless Excel-Like Filtering in WinUI DataGrid 

Filtering is one of the most necessary features of any data grid. With it, users can find the data they require from a huge volume of data sets by applying criteria.

The WinUI DataGrid control is used to display and manipulate tabular data efficiently. Its rich feature set includes data binding, editing, sorting, filtering, grouping, and data virtualization. It has been optimized to work with millions of records and handle high-frequency, real-time updates.

It also provides Excel-like filtering support to filter the rows more intuitively.

In this blog, we will see the various Excel-like filtering options available in the WinUI DataGrid.

Getting started with Excel-like filtering

We can enable Excel-like filtering support for all columns by setting the SfDataGrid.AllowFiltering property to true. The filter icon will be shown in the column headers.

Refer to the following image.

Enabling Excel-Like Filtering in WinUI DataGrid
Enabling Excel-Like Filtering in WinUI DataGrid

By clicking on the filter icon, you can see the Excel-like pop-up menu, as shown in the following image.

WinUI DataGrid with Excel-Like Filtering Pop-Up
WinUI DataGrid with Excel-Like Filtering Pop-Up

Features of Excel-like filtering in WinUI DataGrid

The Excel-like filtering support in our WinUI DataGrid has almost all the options available in the Microsoft Excel filtering menu:

  • Sorting: Easily sort the rows in ascending or descending order.
  • Clear filter: Clear the current filter applied to the column.
  • Advanced filtering.
  • Checkbox filtering.

Let’s look at the latter two options in more detail.

Advanced filtering

With advanced filtering, users can filter for the required data by applying multiple filter conditions with filter criteria. Each type of filter has its own set of filter conditions to apply filtering with ease.

The advanced filtering options are available based on the data type of the columns.

Supported data types:

  • Text
  • Number
  • Date

The following table shows the list of filter conditions supported in advanced filter options.

Text

Number

Date

· Equals

· Does Not Equal

· Begins With

· Does Not Begin With

· Ends With

· Does Not End With

· Contains

· Does Not Contain

· Empty

· Not Empty

· Null

· Not Null

· Equals

· Does Not Equal

· Null

· Not Null

· Less Than

· Less Than or Equal

· Greater Than

· Greater Than or Equal

· Equals

· Does Not Equal

· Before

· Before Or Equal

· After

· After or Equal

· Null

· Not Null

You can also choose whether the AND or OR logical operator should be applied between the two filter conditions you apply in the advanced filter.

Refer to the following GIF image.

Advanced Filtering Support in WinUI DataGrid
Advanced Filtering Support in WinUI DataGrid

Checkbox filtering

Checkboxes are the most common filtering option used to filter rows. By using a checked ListBox in the filter pop-up, you can easily select the data you want to view.  A blank item is added automatically if the column has null or empty data.

Checkbox Filtering Support in WinUI DataGrid
Checkbox Filtering Support in WinUI DataGrid

Events

The following events will be called when we apply filtering through the Excel-like filter pop-up:

  • FilterChanging: This is invoked while applying filtering to a specific column.
  • FilterChanged: This is invoked after the filtering is applied to a specific column.
  • FilterItemsPopulating: This is invoked while populating a list of items in the checked list box.
  • FilterItemsPopulated: This is invoked after the list of items in the checked list boxes is populated.

Programmatic filtering

Along with the Excel-like filtering UI, you can also filter data programmatically through:

  • View filtering
  • Column filtering

View filtering

This feature enables users to apply logic to an entire row. This approach requires a bool return type method with an underlying data object as the parameter. This user-defined method will be called for every row in the DataGrid, and the user can return true or false based on the logic. If the return value is true, then that row will be filtered. Other rows will not be displayed in the view.

View filtering can be achieved by setting the SfDataGrid.View.Filter delegate. You can refresh the view by calling the SfDataGrid.View.RefreshFiltermethod.

Refer to the following code example.

public bool FilterRecords(object data)
{
    string filterText = "Germany";
    var item = data as OrderInfo;

    if (item != null)
    {
        if (item.Country.Equals(filterText))
            return true;
    }
    return false;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (sfDataGrid != null && sfDataGrid.View != null)
    {
    	sfDataGrid.View.Filter = FilterRecords;
    	sfDataGrid.View.RefreshFilter();
    }
}

Refer to the following image.

View Filtering in WinUI DataGrid
View Filtering in WinUI DataGrid

Column filtering

This approach enables users to apply the filter conditions based on specific columns. So, rows will be filtered based on the specific column criteria.

Column filtering can be done using the GridColumn.FilterPredicates property by adding the FilterPredicate to it. You can specify your required criteria in the filter predicate.

In the following example, we will use the OrderID column to filter the data, which has a 1005 value.

sfDataGrid.Columns["OrderID"].FilterPredicates.Add(new FilterPredicate() { FilterType = FilterType.Equals, FilterValue = "1005" });

Refer to the following image.

Programmatic Column Filtering in WinUI DataGrid
Programmatic Column Filtering in WinUI DataGrid

References

For more details, refer to the Excel-like filtering in the WinUI DataGrid GitHub demo and documentation.

Conclusion

Thanks for reading! I hope you enjoyed this blog about Excel-like filtering in Syncfusion’s WinUI DataGrid control. Try out this user-friendly feature and experience seamless filtering!

For current Syncfusion customers, the newest version of Essential Studio is available from the license and downloads page. If you are not yet a customer, you can try our 30-day free trial to check out these new features.

If you have questions, contact us through our support forumsfeedback portal, or support portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top