Skip to main content

Using Filter Builder Dialog

  • 5 minutes to read

ExpressQuantumGrid enables you to filter the data displayed by Views. This functionality is implemented by a View’s DataController property.

Also, the Filter property of the data controller allows you to provide filter conditions for the data displayed by the current View, i.e. reduce the data available as opposed to temporarily suppressing some of it. Refer to the Filtering Data topic for more information.

EQGrid provides a Filter Builder dialog to facilitate creating and applying filter criteria at runtime. The Filter Builder dialog supports all the filter operators available via the Filter property programmatically. In addition, it allows you to save filter criteria to an external file for future use. You can invoke your own Filter Builder dialog by handling the OnFilterDialogShow and OnFilterCustomization events.

The Runtime Filtering topic provides general information on the Filter Builder dialog. This section relates to how you can use the dialog to construct custom filter criteria.

  1. Building filter criteria

  2. Saving to/loading from an external file

1. Building Filter Criteria

Let’s examine the Orders table from the CarsDB database shipped with the EQGrid demos. Each record in the table describes a single order made. It refers to a customer, the product bought, purchase date, payment amount and type, etc.

To invoke the Filter Builder dialog, click the Customize button on the Filter panel. The Customize button is visible if the View’s FilterBox.CustomizeDialog property is set to True. The visibility of the Filter panel is determined by the FilterBox.Visible property.

The following image displays an empty Filter Builder dialog:

Suppose we need to select the orders made between the 11.15.02 and 12.15.02. These criteria are applied to the PurchaseDate column.

Click the press button to add new condition’** box. This will add a new condition to the criteria. Alternatively, you can left-click on the Filter box and select the Add Condition option from the dropdown menu:

As we need to apply the filter criteria to the PurchaseDate column, left-click the column box (next to the ellipsis button) to open the dropdown list displaying the available column names. Then select the PurchaseDate item:

In the operator box, select the BETWEEN item. This will add two empty value boxes to specify the inclusive range for the BETWEEN condition:

Next, you need to specify the range for the BETWEEN operator. You can do this either manually by typing a date using the keyboard or via the date editor that is activated when you click the value box and open the dropdown. The editor used in value boxes is determined by the editor type assigned to the corresponding column:

Now you can apply this filter condition to the View by clicking the Apply button.

In a similar manner, we will add another filter condition to show only the orders with their PaymentType set to AmericanExpress.

Click the press button to add new condition’** box. This adds a new filter condition at the same level as the condition for the PurchaseDate column. In the column box, select the PaymentType item. Then move to the value box and select the Am. Express item using the image combo box editor.

To select orders made by particular customers, we need to add a new filter condition. Suppose that we want to select orders made by three customers.

Customer = ‘Sam Hill’ OR Customer = ‘Karen Holmes’ OR Customer = ‘Bobbie Valentine’

This is a complex filter condition combining three simple conditions with the OR operator. So we cannot just add them at the same root level as for the existing conditions which are combined by an AND operator. Instead, we need to add a group of conditions.

Left-click the ellipsis button for the PaymentType condition and select the Add Group menu item:

Our new complex criteria must combine conditions using the OR operator. To do this, left-click the operator box (by default, it specifies the AND operator) and select the OR item from the dropdown:

The group already contains one condition. You have to add two more conditions at the same level and specify the required customers using value boxes. After doing this, the Filter Builder dialog will look like:

Finally, click the OK button to apply the filter criteria and close the dialog. The grid View now displays only the records matching the set criteria.

2. Saving to/Loading from an External File

The Filter Builder dialog allows you to save filter criteria to and load them from an external file. Clicking the Save As… or Open… buttons activates one of these dialogs.

Filter settings are stored in a file with a flt extension. Starting from version 6 of the ExpressQuatnumGrid, a column in the file is referenced by its name (not by its position in a View). This means that filter settings are correctly restored if columns were deleted from the View after saving the filter to a file. Note that filter criteria saved in the old format will be restored using column positions as references to columns.

See Also