addTableFilter
addTableFilter filters table rows on data that may be in any column.
Options
Information:
Options passed into
addTableFilter.const table = createTable(data, {
filter: addTableFilter({ ... }),
});const table = createTable(data, {
filter: addTableFilter({ ... }),
});fn?: ({ filterValue, value }) => boolean
Custom filter. filterValue is a string; value is serialized to string by default.
initialFilterValue?: string
Default ''.
includeHiddenColumns?: boolean
Whether hidden columns are included. Default false.
serverSide?: boolean
If true, use server-side filtering by updating $data.
Column Options
Information:
Options passed into column definitions.
const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
filter: { ... },
},
}),
]);const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
filter: { ... },
},
}),
]);exclude?: boolean
Exclude the column from search. Default false.
getFilterValue?: (value) => string
Map a cell value to a filterable string. Default serializes value.
Prop Set
Information:
Extensions to the view model. Subscribe to
.props().{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.filter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.filter}
</Subscribe>
{/each}
</Subscribe>
{/each}{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.filter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.filter}
</Subscribe>
{/each}
</Subscribe>
{/each}BodyCell
matches: boolean — whether the cell matches the current filter value.
Plugin State
Information:
State provided by
addTableFilter.const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.filter;const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.filter;preFilteredRows: Readable<BodyRow<Item>[]>
filterValue: Writable<string>
Examples
$filterValue =
| Name | Info | ||||
|---|---|---|---|---|---|
| First Name | Last Name | Age | Status | Visits | Profile Progress |
| Gerhard | Stanton | 28 | complicated | 79 | 26 |
| Hobart | Gutkowski | 30 | complicated | 28 | 6 |
| Jodie | Schaden | 56 | complicated | 75 | 76 |
| Rahsaan | Bailey | 22 | complicated | 84 | 11 |
| Rod | Wilkinson | 60 | single | 62 | 92 |
| Grayson | Morar | 43 | complicated | 56 | 66 |
| Edwina | Dickens | 21 | single | 33 | 94 |
| Clifford | Bergstrom | 20 | complicated | 52 | 64 |
| Tod | Hauck | 35 | single | 4 | 32 |
| Jarret | Kshlerin | 38 | relationship | 12 | 54 |
| Murray | Mohr | 21 | single | 99 | 16 |
| Abbie | Hudson | 40 | single | 14 | 38 |
| Anais | Raynor | 43 | complicated | 17 | 54 |
| Tiara | Koch | 31 | complicated | 6 | 13 |
| Zita | Weimann | 61 | complicated | 56 | 87 |
| Timmy | Cronin | 23 | complicated | 34 | 42 |
| Eliane | Walter | 34 | relationship | 9 | 29 |
| Ellsworth | Terry | 60 | complicated | 7 | 50 |
| Una | Stamm | 43 | complicated | 50 | 93 |
| Elroy | Kub | 56 | complicated | 78 | 5 |
| Renee | Fisher | 36 | single | 50 | 8 |
| Mose | Stiedemann | 41 | relationship | 43 | 84 |
| Houston | Conroy | 30 | relationship | 13 | 50 |
| Ellsworth | Heidenreich | 21 | single | 40 | 12 |
| Alvis | Schultz | 30 | complicated | 33 | 80 |
| Katrine | Ortiz | 55 | complicated | 15 | 42 |
| Evie | Walsh-King | 54 | complicated | 75 | 68 |
| Cary | Bauch | 43 | relationship | 32 | 15 |
| Rosella | Bashirian | 58 | relationship | 21 | 84 |
| Hilda | Kerluke | 59 | relationship | 18 | 87 |