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 the table’s 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. Read
current.props on table components. The lists below are generated from the plugin's TypeScript prop-set type, so they match the published package exactly.BodyCell props cell.current.props.tableFilter
matches: boolean- True if this cell matches the current filter.
Interactions
- Hidden columns are excluded from the search by default. Set
includeHiddenColumns: trueto search their values while they are hidden. - With
addSubRows, a parent row is kept when any descendant matches, and only the matching descendants are shown under it.
Plugin State
Information:
State provided by
addTableFilter.const vm = table.createViewModel(columns)
const { pluginStates } = vm
const { filterValue } = pluginStates.filterconst vm = table.createViewModel(columns)
const { pluginStates } = vm
const { filterValue } = pluginStates.filterfilterValue: Box<string>
The current filter text. Bind an input to it directly:
<input bind:value={filterValue.current} placeholder="Search rows..." /><input bind:value={filterValue.current} placeholder="Search rows..." />preFilteredRows: ReadonlyBox<BodyRow<Item>[]>
The rows before filtering was applied.
Examples
filterValue.current =
| Name | Info | ||||
|---|---|---|---|---|---|
| First Name | Last Name | Age | Status | Visits | Profile Progress |
| Edgar | Tremblay | 24 | complicated | 20 | 5 |
| Madge | McLaughlin | 19 | complicated | 56 | 26 |
| Janessa | Sauer | 32 | single | 22 | 39 |
| Terrance | Bosco | 49 | relationship | 56 | 36 |
| Earnestine | Stoltenberg | 46 | complicated | 28 | 28 |
| Katherine | Hettinger | 51 | single | 75 | 69 |
| Faith | Kilback | 20 | relationship | 24 | 98 |
| Nathanial | Bergstrom | 21 | relationship | 20 | 15 |
| Charlene | Lindgren | 51 | single | 26 | 93 |
| Roscoe | Volkman | 48 | relationship | 36 | 55 |
| Olive | Little | 22 | single | 49 | 93 |
| Corrine | Trantow | 48 | relationship | 14 | 41 |
| Madisen | O'Keefe | 63 | relationship | 43 | 7 |
| Kris | Gibson | 51 | relationship | 90 | 34 |
| Noble | Spencer | 52 | relationship | 36 | 73 |
| Shana | Schmeler | 64 | relationship | 37 | 20 |
| Mossie | Skiles | 59 | single | 9 | 21 |
| Drake | Boyer | 58 | relationship | 54 | 78 |
| Everette | Spencer | 20 | relationship | 5 | 75 |
| Wilfredo | Blanda | 40 | complicated | 6 | 89 |
| Kiara | Kertzmann | 41 | complicated | 58 | 62 |
| Donnie | Fadel | 29 | relationship | 48 | 0 |
| Mariah | Powlowski | 36 | complicated | 4 | 44 |
| Dashawn | Jenkins | 62 | single | 27 | 14 |
| Amir | Franecki | 51 | single | 6 | 29 |
| Nicolas | Stiedemann | 26 | single | 83 | 4 |
| Mariano | Bruen | 42 | relationship | 88 | 93 |
| Guadalupe | Johns | 53 | complicated | 48 | 50 |
| Milan | Friesen | 62 | complicated | 87 | 51 |
| Carrie | Bins | 47 | single | 49 | 68 |