End User Manual
RadDataFilter allows you to create complex filter criteria within unlimited number of filter conditions combined by logical operators.
Build Simple Filter Criteria
To create a filter condition you need to define the column/field, the operator (AND or OR) and the Value. For instance, 'Quantity > 200' is a simple filter condition, where the Quantity is a column/field name, '>' is the "greater than" operator and '200' is the value. Here is how to create this condition using the RadDataFilter user interface.
If no filtering has been applied, RadDataFilter will contain the root operator only.
To add your first filter criteria - click on the green plus sign on the right side. It will create a new row with several elements.
The first DropDown contains all the data fields/columns of the data source, to which RadDataFilter is bound. They are automatically populated, so you do not need to do any code to get them. The second dropdown shows the available logical operators that could be applied against the type of the selected field. For example the text field will have the Contains or Starts With operators, while the DateTime field will have Is Greater Than operators.
Now that we have the field and the operator we need to provide the value. Just type 200 in the TextBox and hit enter. RadDataFilter will query the data source and fill its FilteredSource property with all data that satisfies the 'Quantity > 200' filter criteria. You can show the end result to any ItemsSource control. To further complicate the query, let's assume that we want to show the orders, which Quantity is greater than 200 OR the UnitPrice is less than or equal to 50.
To do so, just click on the And root operator to switch it to Or and then press the green plus sign to add another filter row.
Build Complex Filter Criteria
By using RadDataFilter, you can easily build filter criteria which contains multiple logical (Boolean) operators combining simple filter conditions. First, you need to identify groups of filter conditions. A filter group is a set of simple filter conditions or other groups combined by the same logical operator. You can think of groups as clauses in a filter expression wrapped by round brackets. Let's take a look at the following sample filter criteria:
'OrderDate >= 1-Jan-2007 AND OrderDate <= 31-Dec-2007 OR Quantity > 50 AND Quantity < 100'
In this expression, we'll identify groups by wrapping them with round brackets as follows:
'(OrderDate >= 1-Jan-2007 AND OrderDate <= 31-Dec-2007) OR (Quantity > 50 AND Quantity < 100)'
There are two groups of filter conditions in the example above. Within each group, filter conditions are combined by the same logical operator:
Group 1: OrderDate >= 1-Jan-2007 AND OrderDate <= 31-Dec-2007
Group 2: Quantity > 50 AND Quantity < 100
The groups are combined by the same OR operator. After the filter groups have been identified, the filter expression can be easily built using RadDataFilter.
Change the root logical operator to OR. To do this, click the current AND operator and it will switch to OR.
Add a new filter condition group by clicking the green plus sign. This will create a new filtering row. To create a group - click on its button.
Now change the field column from Quantity to OrderDate and the filter operator from Is equal to to Is greater than or equal to and select the proper date from the built-in calendar.
Now the first group is done, let's create the second one. Click on the green plus sign next to the OR operator to create the next group. Follow step 2 from above to add two conditions to the group.
That's it. The following filter criteria has been applied to the RadDataFilter:
'(OrderDate >= 1-Jan-2007 AND OrderDate <= 31-Dec-2007) OR (Quantity > 50 AND Quantity < 100)'