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 |
| Dalton | DuBuque | 62 | single | 49 | 61 |
| Joshua | Dibbert | 21 | relationship | 74 | 44 |
| Shanelle | Jerde | 32 | complicated | 63 | 58 |
| Dina | Fritsch | 33 | single | 14 | 16 |
| Vickie | Bailey | 27 | relationship | 70 | 78 |
| Kobe | Larkin | 48 | single | 99 | 26 |
| Sarai | Abernathy | 40 | single | 99 | 40 |
| Kasandra | Kuhic | 19 | relationship | 8 | 11 |
| Violette | Schumm | 45 | single | 64 | 82 |
| Tara | Botsford | 35 | single | 3 | 55 |
| Amelia | Hickle | 29 | complicated | 80 | 35 |
| Jeremie | Weimann | 63 | complicated | 11 | 85 |
| Barney | Langosh | 64 | single | 37 | 1 |
| Bernita | Stark | 42 | relationship | 45 | 80 |
| Kiara | Wyman | 56 | complicated | 5 | 19 |
| Mayra | Hessel | 62 | single | 96 | 41 |
| Ernie | Legros | 49 | single | 90 | 97 |
| Noble | Prohaska | 54 | relationship | 98 | 37 |
| Dawson | Hettinger | 56 | single | 6 | 45 |
| Diego | Flatley | 22 | relationship | 81 | 17 |
| Rashawn | McKenzie | 61 | complicated | 6 | 97 |
| Elizabeth | Oberbrunner | 65 | complicated | 10 | 58 |
| Mackenzie | Bartell | 44 | complicated | 36 | 90 |
| Heather | Legros | 64 | relationship | 79 | 50 |
| Leila | Roob | 65 | complicated | 22 | 42 |
| Emily | Kris | 44 | relationship | 26 | 13 |
| Bridie | Parisian | 46 | complicated | 100 | 56 |
| Ludie | Morissette | 46 | single | 61 | 35 |
| Lela | Franecki | 21 | relationship | 35 | 1 |
| Angel | Heidenreich | 46 | relationship | 78 | 63 |