There's more...

You can group the filters with the group tag, which causes them to be rendered slightly closer together than the other filters, but this has semantic implications, too. If you put multiple filters in the same group and activate more than one of them, their domains will be combined with the | operator, while filters and fields not in the same group are combined with the & operator. Sometimes, you might want disjunction for your filters, which is where they filter for mutually exclusive sets, in which case selecting both of them will always lead to an empty result set. Within the same group, you can achieve the same effect with the separator element.

Note that if the user fills in multiple queries for the same field, they will be combined with | too, so you don't need to worry about that.

Apart from field, the filter element can have a context attribute, whose content will be merged with the current context and eventually other context attributes in the search view. This is essential for views that support grouping (refer to the Defining kanban view and Defining graph view recipes), because the resulting context determines the field(s) to be grouped with the group_by key. We'll look into the details of grouping in the appropriate recipes, but the context has other uses, too. For example, you can write a function field that returns different values depending on the context, and then you can change the values by activating a filter.

The search view itself also responds to context keys. In a very similar way to default values when creating records, you can pass default values for a search view through the context. If we had set a context of {'search_default_suppliers': 1} in our previous action, the suppliers filter would have been preselected in the search view. This works only if the filter has a name, though, which is why you should always set it. To set defaults for fields in the search view, use search_default_$fieldname.

Further more, the field and filter elements can have a groups property with the same semantics as in the form views in order to make the element only visible to certain groups.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset