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 |
| Kathryne | Greenfelder | 42 | relationship | 90 | 90 |
| Coralie | Kiehn | 19 | relationship | 46 | 65 |
| Mariana | Bailey | 44 | relationship | 26 | 41 |
| Matilde | Crona | 44 | relationship | 78 | 30 |
| Gilbert | Wolf | 50 | complicated | 91 | 85 |
| Audrey | Lynch | 35 | complicated | 22 | 41 |
| Domingo | Koch | 59 | relationship | 59 | 28 |
| Jackeline | Douglas | 42 | complicated | 8 | 48 |
| Melisa | Pollich | 51 | complicated | 37 | 67 |
| Kiarra | Kilback | 20 | relationship | 24 | 98 |
| Mateo | Reilly | 40 | relationship | 60 | 6 |
| Cloyd | Bradtke | 24 | single | 55 | 18 |
| Marisa | Quigley | 30 | single | 93 | 84 |
| Jayda | Rodriguez | 49 | complicated | 92 | 64 |
| Kavon | Dicki | 52 | single | 79 | 98 |
| Karina | Kuhn | 62 | complicated | 79 | 48 |
| Cyril | Bins | 60 | complicated | 64 | 14 |
| Amani | Renner | 49 | complicated | 48 | 27 |
| Vern | Bernier | 20 | complicated | 8 | 96 |
| Rodolfo | Gibson | 51 | relationship | 90 | 34 |
| Salvatore | Robel | 25 | single | 70 | 84 |
| Flossie | Conn | 33 | relationship | 42 | 88 |
| Shanelle | Witting | 35 | single | 20 | 24 |
| Virgie | Kub | 31 | relationship | 84 | 88 |
| Crystal | Stanton | 33 | complicated | 28 | 43 |
| Austin | Lesch | 55 | single | 23 | 97 |
| Evelyn | Prohaska | 58 | single | 4 | 5 |
| Ellis | Crist | 64 | relationship | 50 | 83 |
| Javonte | Torp | 39 | complicated | 6 | 7 |
| Archibald | Kertzmann | 41 | complicated | 58 | 62 |