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 |
| Eileen | Tremblay | 24 | complicated | 20 | 5 |
| Maria | McLaughlin | 19 | complicated | 56 | 26 |
| Ignatius | Sauer | 32 | single | 22 | 39 |
| Stevie | Bosco | 49 | relationship | 56 | 36 |
| Eloise | Stoltenberg | 46 | complicated | 28 | 28 |
| Kelly | Hettinger | 51 | single | 75 | 69 |
| Eunice | Kilback | 20 | relationship | 24 | 98 |
| Mittie | Bergstrom | 21 | relationship | 20 | 15 |
| Cierra | Lindgren | 51 | single | 26 | 93 |
| Russell | Volkman | 48 | relationship | 36 | 55 |
| Owen | Little | 22 | single | 49 | 93 |
| Della | Trantow | 48 | relationship | 14 | 41 |
| Macey | O'Keefe | 63 | relationship | 43 | 7 |
| Kamryn | Gibson | 51 | relationship | 90 | 34 |
| Patrick | Spencer | 52 | relationship | 36 | 73 |
| Sherry | Schmeler | 64 | relationship | 37 | 20 |
| Maximillia | Skiles | 59 | single | 9 | 21 |
| Earnest | Boyer | 58 | relationship | 54 | 78 |
| Evelyn | Spencer | 20 | relationship | 5 | 75 |
| Wilbert | Blanda | 40 | complicated | 6 | 89 |
| Kristy | Kertzmann | 41 | complicated | 58 | 62 |
| Dwight | Fadel | 29 | relationship | 48 | 0 |
| Maxine | Powlowski | 36 | complicated | 4 | 44 |
| Daryl | Jenkins | 62 | single | 27 | 14 |
| Allie | Franecki | 51 | single | 6 | 29 |
| Owen | Stiedemann | 26 | single | 83 | 4 |
| Matt | Bruen | 42 | relationship | 88 | 93 |
| Ezekiel | Johns | 53 | complicated | 48 | 50 |
| Marcella | Friesen | 62 | complicated | 87 | 51 |
| Chad | Bins | 47 | single | 49 | 68 |