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 |
| William | Collier | 63 | single | 61 | 20 |
| Junior | Stehr | 65 | single | 75 | 14 |
| Amelie | Jast | 33 | single | 98 | 11 |
| Laney | Buckridge | 45 | relationship | 82 | 74 |
| Clifford | Ortiz | 49 | single | 39 | 67 |
| Laverna | Moore | 27 | complicated | 17 | 33 |
| Clemens | Wyman | 24 | complicated | 33 | 95 |
| Clark | Barton | 48 | single | 61 | 16 |
| Alba | Harber | 40 | single | 56 | 49 |
| Ashley | Spencer | 28 | single | 62 | 91 |
| Chad | Bayer | 64 | relationship | 66 | 5 |
| Melody | Lindgren | 57 | complicated | 7 | 76 |
| Lucile | Homenick | 41 | complicated | 3 | 2 |
| Jerod | Larkin | 46 | relationship | 41 | 22 |
| Fabian | McDermott | 52 | relationship | 12 | 25 |
| Janice | Goodwin | 41 | relationship | 59 | 13 |
| Jakob | Johnson | 18 | complicated | 72 | 38 |
| Oleta | Hills-Leuschke | 65 | relationship | 25 | 3 |
| Norberto | Yost | 65 | relationship | 47 | 98 |
| Hazel | Turner | 44 | single | 11 | 36 |
| Henderson | Nicolas | 44 | relationship | 90 | 43 |
| Herman | Wiegand | 39 | relationship | 30 | 20 |
| Elwyn | Champlin | 33 | single | 13 | 91 |
| Cecile | Mills | 56 | relationship | 18 | 95 |
| Virgil | Goyette | 38 | relationship | 35 | 79 |
| Domenick | Zboncak | 57 | relationship | 11 | 58 |
| Mireille | Jacobi | 40 | complicated | 0 | 54 |
| Melvin | Vandervort | 20 | relationship | 23 | 75 |
| Meggie | Rempel | 42 | relationship | 86 | 74 |
| Rylan | Terry | 55 | relationship | 97 | 56 |