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 |
| Alberta | Kertzmann | 33 | complicated | 23 | 78 |
| Trevion | Luettgen | 24 | relationship | 4 | 13 |
| Makayla | Lockman | 64 | relationship | 31 | 2 |
| Glenna | Boyer | 32 | single | 96 | 94 |
| Ollie | Erdman | 41 | single | 100 | 89 |
| Dewayne | Mayer | 46 | relationship | 85 | 22 |
| Orland | Russel | 65 | single | 40 | 97 |
| Julien | Towne | 45 | complicated | 81 | 2 |
| Erwin | Keebler | 32 | complicated | 51 | 97 |
| Brenda | Lemke | 45 | single | 25 | 74 |
| Hadley | Abshire | 37 | single | 50 | 73 |
| Willa | Predovic | 18 | single | 59 | 28 |
| Adriana | Bartell | 24 | single | 88 | 32 |
| Lilliana | Denesik | 44 | single | 53 | 87 |
| Willow | Murray | 34 | relationship | 89 | 99 |
| Helen | Paucek | 50 | relationship | 63 | 1 |
| Aliyah | Greenholt | 63 | relationship | 32 | 71 |
| Jessie | Armstrong | 29 | relationship | 63 | 67 |
| Ian | McGlynn | 28 | single | 41 | 44 |
| Emilia | Lakin | 54 | relationship | 89 | 32 |
| Bethel | Hirthe-Tromp | 25 | relationship | 82 | 59 |
| Christopher | Boyer | 36 | single | 40 | 76 |
| Joanny | Weissnat | 31 | complicated | 37 | 30 |
| Llewellyn | Cremin | 32 | relationship | 89 | 8 |
| Ardella | Skiles | 33 | single | 44 | 70 |
| Alexzander | Lowe | 22 | single | 56 | 92 |
| Keaton | Huels | 55 | single | 19 | 76 |
| Elvis | Willms | 63 | relationship | 4 | 87 |
| Corrine | Kuhic | 54 | complicated | 22 | 50 |
| Giles | Anderson-Waelchi | 18 | single | 85 | 37 |