Current Record: filter #27

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 ...

Current Record: filter #27

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 ...

filter

[Permalink]

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
blog comments powered by Disqus
Powered by Xataface
(c) 2005-2024 All rights reserved