Articles in this section
Category / Section

How to Filter WPF DataGrid with Excel Like Ui filtering?

7 mins read

  Our WPF SfDataGrid feature tour page provides excel like filtering UI and also advanced filter UI to filter the data easily. UI filtering can be enabled by setting SfDataGrid.AllowFiltering property to true , where you can open filter UI by clicking the Filter icon in column header and filter the records.

<syncfusion:SfDataGrid x:Name="dataGrid"    
                               AutoGenerateColumns="False"
                               AllowFiltering="True"
                               ColumnSizer="Star"
                               AllowEditing="True"
                               ItemsSource="{Binding ProductInfo}">

You can enable/disable filtering for particular column by setting GridColumn.AllowFiltering property.

<syncfusion:GridTextColumn    HeaderText="Product"                                                         MappingName="Product"                                                          AllowFiltering="True"  />

 

Note:
  1. GridColumn.AllowFiltering has higher priority than SfDataGrid.AllowFiltering property.
  2. UI filtering is not supported when using on-demand paging by setting UseOnDemandPaging to true.

 

Shows the filter applied in WPF SfDataGrid

Built-in UI Views


SfDataGrid filter UI comprises of two different UIs.

       

  • Checkbox Filter UI - Provides excel like filter interface with list of check boxes.
           
  • Advanced Filter UI - Provides advanced filter options to filter the data.

By default, both Checkbox Filter and Advanced Filter are loaded while opening the filter pop-up. You can switch between AdvancedFilter and CheckboxFilter by using AdvancedFilter button in the UI View.

Displays the two UI views in SfDataGrid

Checkbox Filter UI


In CheckBoxFilterControl a list with checkboxes in show FilterElement, you may need to filter out all data which the checkboxes are checked or filter out all data which the checkboxes are unchecked.

The following are the control parts of Checkbox Filtering.

Control parts of Checkbox Filtering

CheckBoxFilter applied in SfDataGrid

Advanced Filter UI


Advanced filter UI provides multiple filter options to filter the data easily. Filter menu options are loaded based on Advanced filter type by automatically detecting the underlying date type.

Below are the built-in filter types supported.

  • Text Filters – Loads various menu options to filter the display text effectively.
  • Number Filters – Loads various menu options to filter the numeric data.
  • Date Filters – Loads various menu options and DatePicker to filter DateTime type column.

                Text Filters

             Number Filters

             Date Filters


When the string value is bounded to the GridColumn or the items source is dynamic ,then TextFilters are loaded in AdvancedFilterControl.


When integer, double, short, decimal, byte or long are bound to the GridColumn then Number Filters are loaded in AdvancedFilterControl.

 


When the DateTime type value is bound to the GridColumn , then Date Filters are loaded in AdvancedFilterControl.

 

   
   Displays text filter

 
Displays number filter

 
Displays date filter


Filter menu options

  1. Equals
  2. Does Not Equal
  3. Begins With
  4. Does Not Begin With
  5. Ends With
  6. Does Not End With
  7. Contains
  8. Does Not Contain
  9. Empty
  10. Not Empty
  11. Null
  12. Not Null

 

Filter menu options

      1.    Equals

      2.    Does Not Equal

      3.    Null

      4.    Not Null

      5.    Less Than

      6.    Less Than or Equal

      7.    Greater Than

      8.    Greater Than or Equal


Filter menu options

  1. Equals
  2. Does Not Equal
  3. Before
  4. Before Or Equal
  5. After
  6. After Or Equal
  7. Null
  8. Not Null

 

Note:
  1. Null and Not Null options are available only when AllowBlankFilters is set to True.
  2. If the column is GridUnboundColumn or GridMaskColumn, then Text Filters will be loaded.

AdvancedFiltering applied in SfDataGrid

Take a moment to peruse the WPF DataGrid - Filtering documentation, where you can find about Filtering with code examples.

Please refer this link to know about the essential features of WPF DataGrid.

View WPF DataGrid Filter Demo in GitHub.

Conclusion
I hope you enjoyed learning about how to filter WPF DataGrid with excel like ui filtering.
You can refer to our WPF SfDataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Grid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!
Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied