Switch to: V11V10V9V8V7V6V5

Lesson 5 - Simple Filter

In this lesson, you will learn how to easy filter records shown in the form. The fastest way to do it is to use the control filtering. The values entered in the controls of the filter are directly applied to the source set of records. This approach requires zero or a few additional lines of code.

These example lessons make use of a version of the well known Sakila database, the successor to Microsoft's Northwind database. While in this lesson we use a version of Sakila adapted to Valentina DB, the skills are transferable to any other database.

Archives

  • Sakila - Here you can find archives of 'sakila' databases for Valentina DB.

Note, that form uses 'sakila' database with Foreign Key links, download and uncompress it.

  • Project from the previous lessons, download and uncompress it.

Step 1: Open Project

Open an existing local project.

  • On the Start Page click Open Project → Local… and select the project on disk.

Step 2: Duplicate Form

  • Duplicate the form 'simple_form' created in the first lesson using the context menu.
  • Rename a new form as 'simple_filter' and open it for editing.

Step 3: Filter Controls

  • Add a new horizontal layout to hold filter controls.

  • Add a horizontal line to separate filter controls.

  • Drag two fields of the table customer, first_name and last_name, to the new layout.

  • Change the Data Mode property for these fields to Filter And Apply. The filter based on the entered values will be applied automatically.

Step 4: Execute

  • Click Execute to test the form. At first, the form will present all records without filtering.
  • Enter the first name, for example, “MARY” into the first input field. It will find two records which contain this value: “MARY” and “ROSEMARY”

  • Enter the last name, for example, “SMITH”. It will find the single record containing both of these values.

The resulting project you can find here.