Skip to content

Latest commit

 

History

History
41 lines (24 loc) · 2.58 KB

grid-filter-separate-columns-with-or-logic-create-custom-filtering-logic.md

File metadata and controls

41 lines (24 loc) · 2.58 KB
title description type page_title slug res_type
Filter separate columns with OR logic; create custom filtering logic
Filter separate columns with OR logic; create custom filtering logic. Check it now!
how-to
Filter separate columns with OR logic; create custom filtering logic
grid-filter-separate-columns-with-or-logic-create-custom-filtering-logic
kb

HOW TO

Change the filtering of RadGrid so different columns filters are used with an OR logic instead of the default AND logic.

DESCRIPTION

RadGrid uses AND logic for filters coming from separate columns. There isn't a built-in feature that allows you to change that, so you need to create your own filtering expression.

SOLUTIONS

The solution boils down to creating a filter expression that will produce the desired results with the data source that you have.

There are two general ways to do this:

  • Modify the FilterExpression of the table view and set the filters to the columns. This is showcased in the sample attached below.
  • Filter the data source before providing it to the grid in the NeedDataSource event. A similar approach is used in the Custom Paging demo. You can see what filter expressions the grid provides in the [Edit this page Operate with the FilterExpression Manually]({%slug grid/how-to/filtering/operate-with-the-filterexpression-manually %}) help article.

TIPS

You can use an approach similar to the Filter Templates demo and [fire a custom command]({%slug grid/client-side-programming/gridtableview-object/methods/firecommand %}) instead of using a button. This lets you invoke the same functionality in the ItemCommand handler by checking for your custom command name.

If you want to pre-filter the grid for your end user, you can either filter the data source, or use the approach from the [Apply Default Filter on Initial Load]({%slug grid-programmatic-filtering-on-server-side%}) Knowledge-Base article.

Using an OR operator for filtering several values in one column is supported out of the box in the Excel-like filtering where you can check several values that you want present in the filtered data for that column.

DOWNLOADS

A runnable page that shows the approach in action is attached here: