How to Search for multiple Logical values in a List Control

Description

Adding checkboxes to search logical fields in a List control's Search Part may not behave as you expect. A better method is to use dropdownboxes.

When you have a List control (based on a SQL datasource) in a UX component, it is common to add a Search Part to the UX to allow the user to filter the data shown in the List.

If the List contains one or more logical fields (say 'Employee', 'Customer' and 'Vendor'), you may want to search the List as follows:

  • Find all records where 'Employee' is true (ignore the value of 'Customer' and 'Vendor')

  • Find all records where 'Employee' is false (ignore the value of 'Customer' and 'Vendor')

  • Find all records where 'Customer' is true (ignore the value of 'Employee' and 'Vendor')

List with Search Part

If you add logical checkbox controls to your UX to enter your search criteria for 'Employee', 'Customer' and 'Vendor' then you will not be able to perform the above searches because the UX assumes that the value of a unchecked checkbox is false.

If you check 'Customer' and leave 'Employee' and 'Vendor' unchecked, the search submitted to the database would be

Customer = true and Employee = false and Vendor = false

This is not the same as "Find all records where 'Customer' is true (ignore the value of 'Employee' and 'Vendor')". In the List shown below, the record for Smith John was omitted because the 'Vendor' field for the record is true.

Searching Logical Fields in a List using Checkboxes. Only records where 'Customer' is true and 'Employee' and 'Vendor' are false are shown.

The solution is to change the checkbox controls for entering search criteria for 'Employee', 'Customer' and 'Vendor' to dropdownbox controls with the following choices:

true|true
false|false
Setting the choices for a dropdownbox to be used for searching logical fields.

Using dropdownboxes, the search will find records in the List with matching the selected value for logical fields, omitting any logical fields from the search with blank search criteria.

Searching logical fields in a List using dropdownboxes. All records where 'Customer' is true are shown, ignoring the values of 'Employee' and 'Vendor'.
For best results when using a dropdownbox to search logical fields, set the Type for the drodownbox to Character.