addColumnFilters
addColumnFilters filters table rows by specific column values.
Options
Information:
Options passed into
addColumnFilters.const table = createTable(data, {
colFilter: addColumnFilters({ ... }),
});const table = createTable(data, {
colFilter: addColumnFilters({ ... }),
});serverSide?: boolean
If true, filtering will not change $rows. Control filtering by updating $data and use plugin state to drive your fetch.
Defaults to false.
Column Options
Information:
Options passed into column definitions.
const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
colFilter: { ... },
},
}),
]);const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
colFilter: { ... },
},
}),
]);fn: ({ filterValue, value }) => boolean
Defines filter behavior for the column. Return true to keep the row.
render?: (renderProps) => RenderConfig
Renders a control on HeaderCell->props.[pluginName].render. renderProps extends TableState and includes:
id: stringfilterValue: Writable<any>values: Readable<any[]>preFilteredValues: Readable<any[]>preFilteredRows: Readable<BodyRow[]>
initialFilterValue?: any
Initial filter value.
Prop Set
Information:
Extensions to the view model. Subscribe to
.props() on table components.{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.colFilter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.colFilter}
</Subscribe>
{/each}
</Subscribe>
{/each}{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.colFilter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.colFilter}
</Subscribe>
{/each}
</Subscribe>
{/each}Plugin State
Information:
State provided by
addColumnFilters.const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;preFilteredRows: Readable<BodyRow<Item>[]>
Rows before filtering.
filterValues: Writable<Record<Id, FilterValue>>
Active filter values by column id.
Examples
$filterValues = {} | Name | Info | ||||
|---|---|---|---|---|---|
| First Name | Last Name | Age to | Status | Visits | Profile Progress |
| Lorenz | Bartell | 22 | complicated | 89 | 0 |
| Loyal | Turner-Batz | 48 | relationship | 11 | 100 |
| Timothy | Bradtke | 46 | complicated | 88 | 22 |
| Dianna | Boehm | 62 | relationship | 98 | 63 |
| Malika | Skiles | 38 | relationship | 11 | 96 |
| Hertha | Wiegand | 19 | single | 87 | 45 |
| Thad | Nitzsche | 46 | single | 43 | 75 |
| Emilio | Towne | 65 | relationship | 37 | 100 |
| Bradford | Walter | 50 | complicated | 79 | 8 |
| Tomas | Bogisich | 59 | relationship | 22 | 56 |
| Giovani | Veum | 60 | complicated | 13 | 24 |
| Vena | Stehr-Romaguera | 24 | single | 85 | 66 |
| Constance | Simonis-Beahan | 42 | relationship | 8 | 27 |
| Lola | Kohler | 55 | complicated | 77 | 64 |
| Fermin | Stroman | 25 | single | 13 | 99 |
| Shanny | Hayes | 28 | relationship | 32 | 98 |
| Pat | Luettgen | 36 | single | 14 | 11 |
| Sonny | Hickle | 39 | relationship | 42 | 69 |
| Constance | O'Conner | 18 | single | 85 | 94 |
| Dimitri | Graham | 49 | complicated | 72 | 79 |
| Miracle | Hauck | 37 | single | 60 | 82 |
| Vada | Bogisich | 49 | complicated | 40 | 76 |
| Jaylan | Haley | 58 | single | 52 | 30 |
| Demario | VonRueden | 57 | relationship | 19 | 40 |
| Alexandra | Wiegand | 57 | relationship | 19 | 52 |
| Jeanette | Bruen | 37 | single | 86 | 81 |
| Chaya | Nader | 54 | complicated | 78 | 0 |
| Mara | Davis | 35 | relationship | 78 | 86 |
| Gregorio | Sauer | 40 | single | 96 | 99 |
| Diana | Murazik | 41 | single | 41 | 44 |