Skip to content
Steve Hannah edited this page Sep 9, 2019 · 1 revision

Result List Filters

The filter attribute of the fields.ini file

The filter attribute with a value of 1 specifies that a field should be used as a filter field in list view. In list view, any filter fields will provide a select list with all of the possible values in that field. Selecting one of the items in this list will filter the results to only show records of that value.

Example 1: Year, Make, Model

The Fuel Economy Database has three fields with filter=1 : Year, Make, and Model. I.e., in their fields.ini file we have something like:

[Year]
    filter=1

[Make]
    filter=1

[Model]
    filter=1

This causes 3 select lists to appear in list view. See the application here and notice the select lists for Year, Make, and Model just above the list of results.

If you are filtering on a field where an ID is stored in the DB but you are using a vocabulary to associate it with a value, then it will still be sorted on the ID.

If you want to sort on value then you should add a grafted field with the value using the sql directive of the fields.ini file, then use that grafted field as your filter field, like the following:

__sql__ = "select a.*, b.foo_name from a left join b on a.foo_id=b.foo_id"


[foo_name]
    filter=1

Auto Updating Filters

By default, filters are "auto-updating" meaning that the result list will refresh immediately upon selecting a value in any of the filter select lists. You can disable this behaviour (as of Xataface 3.0) via the auto_update_filters preference. I.e., if you add the following to your conf.ini file:

[_prefs]
    auto_update_filters=0

It will add an "Update" button to the "filters" section. You can make adjustments to multiple filter fields, without the resultlist refreshing. When you are ready to apply your filters, you would press the "Update" button.

Filters section with Update button