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 |
| Mathilde | Heathcote | 60 | single | 9 | 100 |
| Dayana | Lehner | 25 | complicated | 37 | 52 |
| Emerson | Raynor | 26 | single | 32 | 6 |
| Brooklyn | Oberbrunner | 59 | single | 18 | 97 |
| Krista | Kovacek | 41 | complicated | 62 | 48 |
| Creola | Schamberger | 40 | relationship | 24 | 30 |
| Katrine | Zulauf | 42 | relationship | 25 | 72 |
| Baby | Rosenbaum | 53 | complicated | 18 | 54 |
| Vicente | Mayert | 37 | single | 38 | 3 |
| Magdalen | Ratke | 43 | relationship | 73 | 76 |
| Vernie | Herman | 55 | single | 41 | 94 |
| Merritt | Mills | 44 | relationship | 94 | 88 |
| Gianni | Shields | 40 | single | 65 | 31 |
| Michale | Schmeler | 58 | relationship | 39 | 81 |
| Alexandra | Blanda | 42 | complicated | 98 | 15 |
| Adelle | Hilll | 46 | single | 100 | 20 |
| Glenda | Jaskolski | 30 | complicated | 53 | 65 |
| Amira | Volkman | 24 | complicated | 89 | 85 |
| Joyce | Smith | 65 | single | 97 | 75 |
| Cristina | Gislason | 43 | single | 36 | 78 |
| Walker | Feest | 62 | relationship | 19 | 50 |
| Asa | Davis | 48 | complicated | 2 | 10 |
| Jason | Koepp | 43 | relationship | 89 | 64 |
| Marcella | Gleichner | 47 | relationship | 9 | 83 |
| Felicity | Heathcote | 27 | complicated | 95 | 31 |
| Easter | Fadel | 44 | single | 64 | 66 |
| Jayson | Witting | 40 | complicated | 85 | 15 |
| Bryana | Brekke | 48 | relationship | 96 | 47 |
| Kayden | Wuckert | 39 | relationship | 52 | 31 |
| Angel | Walsh | 46 | single | 92 | 86 |