Expressions

Adjusting the search capabilities of a combo box control

Combo box controls are pretty powerful. Personally, I prefer them over drop down controls because of several reasons:

  • Allow selection of multiple values
  • Allow users to search by typing in
  • No default value selected if none is specified

The way the search functionality of combo boxes works is when a user types in a text, it searches for those values that have the search text irrespective of the position of the search text.

Let's assume there is a combo box of all usernames. When a user types in a search text e.g. "ha", all results that have "ha" somewhere in the username will be returned e.g. Hardit, Shawn, etc.

A quick demo of the out-of-the-box combo box control:

The Items property of this combo box is set to

Users

While this may work in some situations, it may not be the desired behavior in several situations. For example, if the list of users is too long, I may want the list to be filtered to only show those results that start with the search text. So when a user types in "ha", the results returned are Hardit, Harry etc.

A quick demo of the modified combo box control:

The way this can be achieved is by setting the Items property of a combo box to:

Filter(Users, StartsWith('Full Name', ComboBox.SearchText))

The expression filters the list of users to only those that have their full name starting with the search text.

This is an example to illustrate how the behavior of a combo box can be adjusted. The expression can be modified as needed.

Have fun! Get addicted!

Leave a Reply