Examples of Using the Filter Editor
The Filter Editor allows you to filter data (display those records that meet specific requirements), by visually constructing filter criteria in a straightforward graphical form.
The following sections demonstrate how to construct filter criteria using the Filter Editor.
How to Construct a Simple Filter Condition
Basically, filter conditions specify what data to select from a data source and display in a data-bound control. A typical simple filter condition consists of three parts: the column/field name, operator and a value(s). For instance, '[Discount] >= 0.05' is a simple filter condition, where '[Discount]' is a field name, '>=' is an operator and '0.05' is a value. This condition when applied to a data-aware control will display records that have values in the Discount column greater than or equal to 0.05. Here is how to create this condition via the Filter Editor (it's assumed that the underlying data source contains the Discount column, otherwise, this column will not be accessible in the Filter Editor's column list):
Invoke the Filter Editor.
To invoke the Filter Editor in a grid control, right-click any grid column's header and select the Filter Editor option.
To learn how to invoke the Filter Editor for other controls, see corresponding sections in this documentation.
Select a column.
To filter against the Discount column, click the column name field. This will display the list of available columns. Select the Discount column in this list:
Select a comparison operator.
Click the operator field to choose the required operator.
The comparison operator list displays only those operators that are supported by the current column's data type. For instance, the Discount column is of the numeric type, and the operator list doesn't display the 'Begins with' operator and other operators that are related to strings.
Enter a value.
Now, click the value box and enter a comparison value ('0.05'):
Save changes.
Click OK or Apply, to filter data using the created filter condition. The grid will show the filter panel displaying the current filter criteria:
The filter panel will contain the 'Edit Filter' button, which also allows you to invoke the Filter Editor.
How to Construct Filter Criteria with Multiple Conditions Joined by One Logical Operator
Filter criteria typically consist of two or more simple filter conditions combined by logical operators (AND, OR, NOT AND, NOT OR). The following example shows how to construct filter criteria in the Filter Editor that consist of multiple conditions combined by one logical operator. The "[ProductName] = 'Tofu' AND [Discount] >= 0.1 AND [Quantity] > 99" filter expression contains three simple filter conditions combined by the AND operator. To construct it, do the following:
Invoke the Filter Editor. When the Filter Editor is invoked for a grid control, the Filter Editor may display an unfinished new filter condition:
Set the condition's operator to Equals and operand value to 'Tofu' (as described in the previous section):
To add one more condition, press the button next to the group's AND operator. This will create a new condition under the current one:
For the second condition, set the column to 'Unit Price', operator to '>=' and operand value to '100':
To add a third condition to the same group, click the button again. Set the condition's column to 'Units in Stock', operator to '>' and operand value to '50'. Below is the result:
Click OK or Apply, to apply the created filter criteria.
How to Construct Filter Criteria Involving Different Logical Operators
Some filter criteria contain multiple logical (Boolean) operators combining simple filter conditions. For instance, you want to see items whose price is under 10, and at the same time, the available quantity is also less than 10. At the same time, you may also want to see those items whose price is over 10, while the available quantity is also greater than 10.
The resulting condition will look like this:
(Price is less than 10 AND Quantity is less than 10) OR (Price is greater than 10 AND Quantity is greater than 10)
This is how you can do this:
Invoke the Filter Editor.
Clear existing filter conditions (if any) by clicking the button:
Change the root logical operator to OR. To do this, click the current AND operator and select OR:
Add a new filter condition group by clicking the OR operator and selecting Add Group.
For the created condition, set the column to 'UnitPrice', operator to '<' and operand value to '10':
Click the button to add a new condition to the current group:
For the new condition, set the column to 'Quantity', operator to '<' and operand value to '10':
Add a new filter condition group. To do this, click the root OR operator and select Add Group.
For the condition within the created group, set the column to 'UnitPrice', operator to '>' and operand value to '10':
Click the button to add a new condition to the new group. For the new condition, set the column to 'Quantity', operator to '>' and operand value to '10':
Click OK or Apply, to apply the created filter criteria.