Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Filters

A filter narrows the list to rows matching a value the user picks. Only a value a declared filter accepts reaches the query.

list:
  filters:
    status:     { type: select, options: [{ value: draft, label: Draft }, { value: live, label: Live }], default_value: live }
    featured:   { type: boolean }
    author:     { type: text }
    views:      { type: number }
    created_at: { type: date, permission: acme.blog.audit }
KeyDefaultDescription
labelfrom the keyThe control’s label.
typetextboolean, select, text, number or date.
optionsA select filter’s choices: a list of { value, label }, or the name of an option source. Required for select.
depends_onnoneOn a select with a source: the filters whose values the source reads. See select.
default_valuenoneApplied when the request names no value for this filter: the screen opens already narrowed. Clearing it is still “no filter”.
permissionnoneA user without it does not see the filter, and its default is not applied.

A key written bare (author:) is a text filter with every default.

list:
  related:
    author: { entity: authors, belongs_to: author_id }
  filters:
    views_min:   { label: Views at least, type: number, column: views, match: at_least }
    views_max:   { label: Views at most, type: number, column: views, match: at_most }
    author_city: { label: Author's city, type: text, column: city, related: author }
KeyDefaultDescription
columnthe filter’s keyThe column compared, so two filters narrow one column.
matchequalsOn a number filter: equals, at_least or at_most.
relatednoneA record under the list’s related; the filter compares its column.

Pick a scope type

TypeThe value reaches the query as
boolean1 or 0: rows where the column is true or false.
selectA declared value, matched exactly; any other value is dropped.
textA substring match, folded the way the search box folds.
numberA whole number, matched exactly.
dateA YYYY-MM-DD day; a date column and a stored timestamp both answer.

Each type, with its example, is on Filter Scopes.

Declare a filter from code

use laterite_admin::list::{FilterOption, ListFilter};

let status = ListFilter::select("status", "Status", vec![
    FilterOption::new("draft", "Draft"),
    FilterOption::new("live", "Live"),
]).default_value("live");
let created = ListFilter::date("created_at", "Created").require("acme.blog.audit");
ConstructorType
ListFilter::boolean(field, label)boolean
ListFilter::select(field, label, options)select
ListFilter::select_from(field, label, source)select, its choices from an option source; .depends_on([..]) names the filters it follows.
ListFilter::text(field, label)text
ListFilter::number(field, label)number
ListFilter::date(field, label)date
ListFilter::of(field, label, type)Any declared type, with no options.
MethodSets
.column(name)column
.at_least(), .at_most()match
.related(name)related
.default_value(value)default_value
.require(permission)permission

Carry a filter in a URL

/admin/posts?f_status=draft&f_featured=1&q=launch&sort=created_at&dir=desc
ParameterValue
f_<name>The filter’s value.
qThe search.
sort, dirThe sort column and asc or desc.

The export link carries the same parameters and downloads the list the screen shows.