Put filters in your programs

José Luis Sánchez
Harbour Magazine
Published in
3 min readJan 31, 2018

In my Windows applications I use a self-made interface that I called FSDI — full simple display interface — and I’d published published several posts about it — in Spanish — in my blog cincomundos and can be downloaded with the code of Colossus that I share at GitHub.

This interface consists basically of three parts:

  1. A side bar of actions, that allows the user choose which action want to do.
  2. A configurable grid that shows the data of a DBF file or relation.
  3. A row of tabs in the bottom of the grid that allows the user select the sorting of the data.
FSDI in Fester, my program for manage comparsas de moros y cristianos.

The problem with this interface is that it is too rigid. They usually show all the DBF data unless a condition has been included in an index. To add flexibility to the data to be displayed we can include filtering options.

The filtering option in the action bar displays a menu with all the filtering options and the option of removing the filter. I usually include filters for all foreign keys of the table, and also for some value or range de values like date ranges, marking fields, etc. Before filtering the user can select the desired value in an auxiliary form.

Filtering option and menu of possible filters.

In Harbour we can define filters over a DBF file with the sentence dbSetFilter([<bCondition>], [<cCondition>]) and setting the conditions as codeblocks. The good of filters is that you can do all other actions over your table like changing the index order or seek for a value, and this action will only be preformed over filtered values.

One problem that we could have when using filters is that we would perform an action for the whole table, and in this case we have to take care of removing the filter and set it again. We can save the filter expression with the dbFilter() function, and delete it with dbClearFilter() function.

One important question, in my opinion, when we create a filter is that the user user must have visual knowledge of it, that is, we must tell our user that there is a filter activated. In my programs I do this in two ways:

  1. Adding the name of the filter to the name of the maintenance in the action bar.
  2. Changing the color of the label of the filtering option to red.

Once the filter is removed, all these visual elements disappear.

The possibility of defining filters on tables is an existing option in Harbour that we can easily include in our programs, which will allow us to add a great flexibility to them. It is important that when we apply filters we do it so that the user clearly sees that there is an active filter, and does not lead to confusion.

--

--