Table Component: Filters & URL Sync
Filters allow users to slice datasets and sync selections across page refreshes.
[!IMPORTANT] Schema-Driven Filters: Table filters must be generated automatically from the OpenAPI schema. Manually writing filter components is deprecated. Refer to the Migration to Generated Table Filters guide for details on configuring and running
node generate-filters.cjs.
Filter Integration Pattern
To integrate a generated filter:
- Fetch the active values using
useFilterValues(tableId). - Map the Redux filter values to query params using the generated selector
select{Name}Filter. - Always memoize the filter object to prevent unnecessary API fetches and infinite re-render loops.
- Pass the filter object to
useTableand the generated filter component to theTablecomponent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Filter Layout Positions
The filterPosition prop controls where the filter fields are displayed:
| Position | Behavior |
|---|---|
header |
Filters are always visible inside the Card Header area. |
menu |
Filters are housed in a dropdown menu, toggled via a filter button. |
sidebar |
Filters open inside a sliding side drawer/panel. |
URL Synchronization
Filters can be synced to URL query parameters for shareable links by setting syncFiltersToURL: true inside useTable options:
1 2 3 4 5 6 | |
When enabled:
- Initial load populates the Redux store from URL search params.
- Filter badges/chips are automatically displayed in the filter bar.
- SPA navigation preserves query strings, restoring filter states on page reload or back navigation.
URL Compact Serialization Format
Filters are stored in URL query parameters with compact encoding:
| Value Type | URL Format | Example |
|---|---|---|
| String | Direct value | ?name=test |
| Object with UUID | uuid::name |
?org=abc123::My+Org |
| Array of objects | [uuid1::name1, uuid2::name2] |
?tags=["a1::T1","a2::T2"] |
| Boolean | true/false |
?active=true |
The compact uuid::name format keeps URLs shorter while preserving display names for filter badges without needing additional API lookup calls.
Cross-Page Filters (Resources Sidebar)
The Resources sidebar filter (src/navigation/sidebar/resources-filter/) is a special case that:
- Syncs
organizationandprojectfilters across multiple resource tables. - Persists selections to
localStoragefor session persistence. - Syncs parameters to the URL for shareable links.
Priority resolution order:
- URL params (highest) - for shareable links.
- localStorage - for session persistence.
- No filter - shows all resources.
Inline Filters
Users can quickly filter table data by clicking values directly in the table cells, without opening filter menus. When a column configuration has inlineFilter and filter enabled:
- A filter icon appears when hovering over cells in that column.
- Clicking the icon adds a filter using the cell's value.
- The
inlineFilterfunction transforms row data into the required filter value format.
1 2 3 4 5 6 7 8 9 | |
Filter facets
A filter can offer only the values that still have rows under the table's
other filters and search, each with its count. The list endpoint has to
serve a facets action (mastermind's FacetsMixin, see
waldur_core/core/facets.py), which counts every facet under all filters
except its own, so a selection can always be changed.
Opt the table in by passing the SDK's …FacetsList function, and each
filter by naming its facet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
- A filter asks for its own facet when it mounts, which is when it is
opened, with exactly the params the table fetches its rows with (
filterplus the search term). Fixed params thatcreateFetcheradds itself go infacets.query, path params of a nested list infacets.path. SelectFilterkeeps the options the facet has, plus the current selection.AsyncSelectFilterlists the facet's values instead of callingloadOptions:facetOption(valueKey, labelKey)builds its option shape from a facet value. A truncated facet is searched on the server.- Counts show in the menu only, not in the chip, through
formatOptionLabel; a filter that passes its own still draws the label, and the count follows it. - A
SelectFilterwithoutoptionslists the facet's values themselves, built withfacetOption(default{ value, label }): for values only the server knows, such as a status synced from a service desk. - Without
facetson the table, or withoutfaceton the filter, the filter behaves as before, so a filter component shared by several tables can name its facet once. - Generated filters take
facet: <name>ingenerate-filters-config.yaml.