Our flexible WPF datagrid, FlexGrid, supports many ways to filter data. This blog explores all supported filtering features to help you best decide which to implement in your application.

Column Filter – Set Search Criteria in the Column Header

One of the most basic ways to filter data in FlexGrid is the column filter. The C1FlexGridFilter extension class extends the C1FlexGrid to provide Excel-style column filtering. Once column filtering is enabled, moving the mouse over the column headers shows a drop-down button that can be used to edit the filter applied to the column.

The filter supports two modes:

  • Value Mode: The editor displays a list containing all the values present in the column. Users may use the list to select one or more values to be displayed.
  • Condition Mode: The editor displays two conditions that consist of an operator and a comparison parameter (e.g. 'greater than' and '2.5'). The conditions are combined with an 'and' or an 'or' operator.

This type of filter is particularly useful when applied to a column with few options for data entry variation. For example, with a FlexGrid displaying a list of products that contain a name, color, and price, you can select a column to apply a column filter to only show entries that are priced over a set amount from the “Price” column. You could also set a column filter that shows only products by specific color, based on the “Color” column. These filters can be applied via the designer or programmatically.

  • Pros: Easy to utilize, implement, and understand.

  • Cons: Limited to only filtering entire dataset by individual column data. Not useful when used on a column with many unique entries, such as a “Names” column.

The link to the sample can be found here.

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

Filter Row – Searches Individual Column for Keyword

Filter rows can be used to implement filtering across various columns simultaneously based on whichever typed criteria you want. This requires an additional row at the top of the dataset that is used for filtering the entries beneath it. With this type of filter, it is possible to filter out data entries by setting filter criteria on two or more separate columns at the same time. For example, you could easily filter out a specific dataset by filtering two separate columns by two separate prefixes.

  • Pros: Can apply the filter on each column by using a text-box above. Can be used in conjunction with the FilterEditor to apply more complex filters. Has the C1FlexGridFilterRow class associated with it that contains public fields, methods, and properties built-in for ease of use.

  • Cons: Can be limited in complex filtering capabilities unless used in conjunction with other filter classes.

The link to the sample can be found here. (Note: solution file for this sample is found separately at this link).

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

Full-Text Filter – Searches Every Column for Keyword

Full-Text filters allow users to easily find specific data entries by entering in the text of the entry they are searching for. The entire dataset will then be searched for the term entered within the text box associated with the filter. Through the use of the C1FullTextFilter class properties, the Full-Text filter can be made more strict as needed.

  • Pros: Filters the grid’s data source based on user input to return search results using the C1FullTextFilter class. Useful for exact searches and has properties such as “Match Case” that can make the filter more strict. Allows the use of regular expressions and other filter manipulations such as wildcard characters to create very specific custom search filters based on user needs.

  • Cons: Unable to apply two different filters in an OR operator relationship without more extensive code being written during implementation. Filter is applied to the data source of the FlexGrid by default.

The link to sample can be found here.

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

Datafilter – Select Filters Through Accompanying Side Menu

Datafilters are a useful way for quickly sorting through data grids by creating pre-set filters that can be applied through an accompanying side-panel to the grid. Inside the side-panel, simply select the filter properties you would like to apply to the grid. Multiple filters can be applied at once, and you can easily deselect the filters by clicking on them again or removing the values. This type of filter is great for very large data sets that need to be filtered out by the end-user at run-time, where an accompanying filter UI will make that process easier.

  • Pros: Acts as a separate control tied to the FlexGrid by appearing on the side and allowing users to click on the filters they would like applied to the data. Intuitive way for end-users to filter through large datasets.

  • Cons: Doesn’t allow for custom, specific entry filtering like a key-word search, unless used in conjunction with another filter type. Requires time and effort to set up UI and logic for the filter.

The link to the sample can be found here.

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

FilterEditor – AND/OR Logic Filters

The FilterEditor class allows users to apply their own conditional operator logic using AND/OR statements to create their own filters to apply on their datasets. This is similar to Microsoft’s CRM filter expressions, where users can set a filter based on conditional expressions. This type of filter is good when trying to filter a dataset across two or more sets of different criteria requirements, as each set of filter criteria can be linked through conditional operators by the end-user. The FilterEditor control represents a filter in the form of a tree. Tree nodes can be logical conditions "AND" and "OR" or a filter for a data source property.

  • Pros: Allows the user of conditional operator logic across sets of filters, and can be used on unbound grid.

  • Cons: Harder to implement, must be used on a collection of objects for best results.

The link to the sample can be found here.

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

Custom Filtering – Add Custom Icons and Filter Designs

Custom filtering is exactly what the name implies: a way for users to specifically handle unique filtering options based on whatever cell properties they would like. Custom filtering is achieved through the use of our C1DataFilter class. The obvious advantage to using custom filters is having the freedom to design a specific filter in a way that is easiest for the end-user to understand and interact with. However, this type of filter will require more manual code behind the scenes in order to handle the filtering. Some examples of custom filtering include an interactive map that filters based on location selected, or colored icons that filter based on the color selected. This type of filter is especially useful when filter design presentation matters.

  • Pros: Very customizable, open to however the developer is looking to design their application, and easy to achieve through the C1DataFilter class.

  • Cons: Requires more background code to set-up the filter UI, such as colors, icons, maps, designs, etc.

The link to the sample can be found here.

The download link can be found here.

A Guide to Filtering a WPF DataGrid Using FlexGrid

Try ComponentOne Studio

Download the latest version of ComponentOne Studio Enterprise

Download Now!