Form Editor - Filtering
The data displayed in a Valentina Form can be filtered in two different ways:
- Using the standard filtering controls
- Applying a custom filter condition
The simplest way to filter data by one or multiple columns is to use the database controls in the filter mode.
The following controls can be switched to the filter mode:
All of them are bound to the specific fields, therefore, the filter is applied to these fields.
They have the following data modes for filtering:
- Filter - The value for filtering can be assigned but the filter is not applied to the field automatically and requires calling the applyFilters method of the cursor.
- Filter And Apply - The filter is automatically applied to the field after the user input.
The control in the filter mode is marked with the magnifying glass icon:
Once the filter is applied, all values for the filter are combined using the AND operation to generate a query, similar to the following:
SELECT f1, f2, f3 WHERE LOWER( "f1" ) LIKE '%filter_value1%' AND LOWER( "f2" ) LIKE '%filter_value2%';
In order to define more complex filtering conditions, you should use a custom filter.
The filtering condition is passed to the addFilter method of the cursor, for example:
records = this.table.getTableCursor( this.name ); records.addFilter( 'f1 > 10' );
To apply this filter to the cursor the applyFilters method must be called:
The filter string becomes the part of the WHERE clause, like:
SELECT f1, f2 FROM t1 WHERE f1 > 10;
In order to remove the filtering or to apply a new filter, clearFilters method must be called: