Skip to content

useTableFilterState

@astryxdesign/core v0.7.1 · useTableFilterState

Usage ​

Managed state hook for table filtering. Returns the current filter map, an onChange handler, and a way to clear everything. Pass the map and the handler to useTableFiltering, and the map to applyTableFilters() to get the matching rows.

ts
import { useTableFilterState } from '@astryx-vue/core/Table'

A filter is "off" when its key is missing. Setting null, an empty string, or an empty array removes the key instead of storing an empty value, so a truthy key in the map always means a live filter.

Give it an initial map when the table should open with a filter already applied. Pass the map directly, or wrap it as initialState. The initial object is shallow copied, so later writes never touch it.

ts
const direct = useTableFilterState({ role: 'Engineer' })
const wrapped = useTableFilterState({ initialState: { role: 'Engineer' } })

Examples ​

Table — Inline Filters

Name
Email
Role
Department
Alice Johnsonalice@example.comEngineerPlatform
Bob Smithbob@example.comDesignerProduct
Charlie Browncharlie@example.comManagerPlatform
Diana Princediana@example.comEngineerInfra
Eve Daviseve@example.comAdminOperations

Inline filter controls with the filter map held by useTableFilterState.

Table — Popover Filters

Name
Email
Role
Department
Alicealice@example.comEngineerPlatform
Bobbob@example.comDesignerProduct
Charliecharlie@example.comManagerPlatform
Dianadiana@example.comEngineerInfrastructure
Eveeve@example.comAdminOperations

Popover filter controls with the same managed state.