RFC 0069 — Filters: a column's own
Status: implemented (2026-11-28) · Target: 0.63.0 · builds on RFC 0012, RFC 0067 and RFC 0068 · see Decisions
Summary
The search box finds "Ada" anywhere in a row. It can't say "the open
invoices", "over 10,000", "due this month": the questions a list of
records is asked all day. Today an app that wants them builds its own
controls over Table, writes them into query by hand, and adds the
WHEREs to the resource's index command itself; each app's look and
keys differ, and the generated resources have none.
This RFC gives a column a filter, the table the controls, and
make:resource the backend half:
<Table
page={invoices}
bind:query
columns={[
"number",
{ key: "customer", filter: "text" },
{ key: "status", filter: { options: [["open", "Open"], ["paid", "Paid"], ["overdue", "Overdue"]] } },
{ key: "due", filter: "dates" },
{ key: "amount", align: "end", filter: "range", total: "sum" },
]}
/>
filteron a column:"text"(contains),{ options }(one or more of them),"range"(a number from, to) or"dates"(a day from, to)."options"alone takes the values the rows have (forrows).- The control opens from a funnel on the column's header: a popover with the field, Apply and Clear. An active filter shows as a chip over the table ("Status: Open, Overdue ×"), and Clear filters takes them all off.
query.filtersis where they go:{ status: ["open", "overdue"], amount: { min: 10000 }, due: { from: "2026-11-01", to: "2026-11-30" } }. Arowstable filters itself; a livepage's command gets them, as it gets the search and the sort.make:resourcewritesfiltersinto the index command: aFILTERABLEallowlist per column and kind, and theWHEREs, so no filter from the frontend reaches SQL unchecked.- The totals (RFC 0067), the export (RFC 0066) and the summary are over what's filtered.
Motivation
- Lists are filtered more than they're searched. "Overdue", "this month", "over a limit" are a filter each; a search can't say them.
- The backend has to do it. A live page of 4,000 invoices can't be filtered in the window; the command must, and safely.
- One way for every list. Each app building its own filter bar is each app's keys, chips and words, and an assistant that can't tell what a list is filtered by.
- The generated resources are the first lists an app has. If they
can't filter, every app writes the same code after
make:resource.
Current state (0.63, with RFCs 0066–0068)
Table:search(a box,query.search),sortable(query.sort,query.direction), paging (query.page);rowsdoes them itself, a livepage's command does them fromquery.make:resource's index command:{Ty}Query { search, sort, direction, page, per_page },SORTABLEandSEARCHABLEallowlists,paginate.- The query builder has
where_in,where_gte,where_lte,where_between,where_like,when_some.
Design
A column's filter
filter |
The control | query.filters[key] |
Matches |
|---|---|---|---|
"text" |
a field | "ada" |
contains, ignoring case |
{ options: [[value, label], …] } |
checkboxes | ["open", "overdue"] |
one of them |
"options" |
checkboxes of the values in rows |
the same | the same |
"range" |
two number fields, from and to | { min?, max? } |
at least, at most |
"dates" |
a DateRangePicker |
{ from?, to? } (ISO days) |
on or after, on or before |
An empty filter is no filter (and isn't in query.filters).
The controls
A sortable header is a button that sorts; a filterable one gets a second,
small button beside its label: a funnel, filled when the column is
filtered, named "Filter Status" (and "Status, filtered" when it is). It
opens a Popover under the header with the control,
Apply (Enter) and Clear; Esc closes it, focus back on the funnel.
Over the table, beside the search, a chip a filter, said as what it is:
"Status: Open, Overdue", "Amount: 10,000 or more", "Due: Nov 1 – Nov 30".
A chip's × clears it; Clear filters clears every one. The chips are a
list named "Filters", and each change is said ("3 of 412 shown" for
rows, the page's total for a live one).
Where they go
query.filters is written with page: 1, as a search is. A rows table
filters before it searches and sorts; a live page re-runs its query
with them. The totals (RFC 0067) and the export (RFC 0066) are of the
filtered rows; the table's summary for the assistant says the filters.
The backend: make:resource
The index command's query gets filters:
pub struct InvoiceQuery {
pub search: Option<String>,
pub filters: InvoiceFilters,
// sort, direction, page, per_page as before
}
/// The list's filters, one a filterable column: anything else is ignored.
pub struct InvoiceFilters {
pub status: Option<Vec<String>>,
pub amount: Option<Range<f64>>,
pub due: Option<Dates>,
pub customer: Option<String>,
}
Range { min, max } and Dates { from, to } are elyra::db::filter's,
with apply helpers (where_gte, where_lte, where_in, where_like
with % and _ escaped). The struct is typed from the model's fields,
so a filter on a field the model doesn't have, or of the wrong kind,
doesn't compile and can't be sent: serde drops unknown keys, and the
generated TypeScript types say what's there. make:resource makes a
filter for each field by its type (an enum or a string with few values:
options; a number: range; a date: dates; other text: text), and the
generated list's columns have filter to match.
Words
elyra.table.filter ("Filter :column"), filtered (":column,
filtered"), apply, clearFilter, clearFilters, filters
("Filters"), atLeast, atMost, between, shown (":count of :total
shown"), in English and Norwegian.
Testing
- Each kind over
rows: text, options (given and from the rows), range, dates; empty ones dropped; with the search and the sort. - The popover's keys and focus; the chips and their ×; Clear filters; the live region.
- A live
page:query.filterswritten withpage: 1. - Totals and the export over the filtered rows.
- The generated command: each kind's
WHERE,%and_in a text filter, an unknown key ignored, a model test over SQLite (and the MySQL/Postgres job). - A browser check in the docs: filter a status and a range, clear one.
Implementation plan
internal/filters.js: matching rows, a filter's text for its chip, held by tests without a DOM.Table's funnels, popovers and chips;query.filters; the words.elyra::db::filter(Range,Dates, the helpers), with tests.make:resource: the filters struct, theWHEREs, the columns'filter; its tests and therata newsmoke test.- Docs (
docs/ui/table.md,docs/resources.md), CHANGELOG.
Open questions
- Funnels on the headers, or a filter bar over the table? Recommendation: funnels, with the chips over the table. The filter sits on the column it filters, the chips say what's on, and a table with ten filterable columns doesn't grow a bar of ten fields.
"options"from the rows' values, forrows? Recommendation: yes, forrowsonly; a live page has a page of the values, not all of them, so it needs{ options }.- A typed filters struct, or a map of column to filter? Recommendation: typed. It's the allowlist and the types at once, and the TypeScript side gets it from codegen; a map needs both written by hand.
- Kept with
persist, as the columns are? Recommendation: no. A filter is a question asked now; a list that opens filtered by last week's question hides rows. (Saved views are a later RFC.) - Filters in the Laravel package's resources too?
Recommendation: not in this RFC. The table sends
query.filtersto any backend; the Laravel side is its own change, if apps ask.
As built
ui/src/internal/filters.js:kindOf,optionsOf,isEmpty,activeFilters,filterRowsandchipText, plain functions. A row's day is its value's first ten characters, so a time on the last day is in; a range passes numbers only.- The panel is the table's own, not a
Popover: that one is a button of its own (32 px, with a chevron), too big for a header. The funnel is a 20 px button beside the label, and the panel is placed under it with the sameplace,onOutsideandfocusablesthe popovers use. Esc and a click outside close it without applying. query.filtersholds only the filters that filter something; with none, it'snull. A range is written with both ends ({ min, max }, the unset onenull).- The chips are over the table, under the search and the Columns
menu; Clear filters shows with two or more. The live region says "3 of
412 shown" for
rows, and the total for a live page. where_containsisLOWER(col) LIKE LOWER(?) ESCAPE '!':!is the escape, because a backslash means different things in MySQL's string literals and the others'.Query::filter_*leave aNone, empty or blank filter out;filter_datesdrops a day that isn't an ISO day and makesto"before the next day".make:resource: a field's filter by its kind and format: text (contains), a date field's days, an integer's or a float's range (Range<i64>,Range<f64>), abool's yes and no; none on a reference, a file or a JSON cast. The struct's fields are renamed to their columns where they differ, so the list's keys are the columns. A model with nothing to filter has nofilters. Its tests filter by the first text field.- The smoke test (
scripts/smoke-resource.sh) generates a resource, runs its tests, clippy and fmt, and in Chrome sets a filter on the list and checks the live query'sfiltersandpage: 1, and the chip's ×. - Checked against MySQL and Postgres by
model_servers.rsin CI (filterson each), and SQLite locally.
Decisions
- Funnels on the headers, and chips over the table; no filter bar.
"options"from the rows' values, forrowsonly.- A typed filters struct in the generated command.
- Filters aren't kept with
persist. - No filters in the Laravel package in this RFC.
Not in this RFC
- Saved views (a named set of filters, columns and sort).
- Filters joined by OR, or on related records.
- Filters in the Laravel package.
Alternatives considered
- A filter bar of fields over the table: always there, and as wide as the columns that filter.
- Only the search, with a syntax (
status:open amount:>10000): fast for some, unknown to most, and nothing for the keyboard to land on. - A map of filters in the command: an allowlist and a type per key by hand, in every resource.