addColumnFilters
addColumnFilters filters table rows by specific column values.
Options
Information:
Options passed into
addColumnFilters.const table = createTable(data, {
colFilter: addColumnFilters({ ... }),
});const table = createTable(data, {
colFilter: addColumnFilters({ ... }),
});serverSide?: boolean
If true, filtering will not change $rows. Control filtering by updating $data and use plugin state to drive your fetch.
Defaults to false.
Column Options
Information:
Options passed into column definitions.
const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
colFilter: { ... },
},
}),
]);const columns = table.createColumns([
table.column({
header: 'Name',
accessor: 'name',
plugins: {
colFilter: { ... },
},
}),
]);fn: ({ filterValue, value }) => boolean
Defines filter behavior for the column. Return true to keep the row.
render?: (renderProps) => RenderConfig
Renders a control on HeaderCell->props.[pluginName].render. renderProps extends TableState and includes:
id: stringfilterValue: Writable<any>values: Readable<any[]>preFilteredValues: Readable<any[]>preFilteredRows: Readable<BodyRow[]>
initialFilterValue?: any
Initial filter value.
Prop Set
Information:
Extensions to the view model. Subscribe to
.props() on table components.{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.colFilter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.colFilter}
</Subscribe>
{/each}
</Subscribe>
{/each}{#each $headerRows as headerRow (headerRow.id)}
<Subscribe rowProps={headerRow.props()} let:rowProps>
{rowProps.colFilter}
{#each headerRow.cells as cell (cell.id)}
<Subscribe props={cell.props()} let:props>
{props.colFilter}
</Subscribe>
{/each}
</Subscribe>
{/each}Plugin State
Information:
State provided by
addColumnFilters.const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;preFilteredRows: Readable<BodyRow<Item>[]>
Rows before filtering.
filterValues: Writable<Record<Id, FilterValue>>
Active filter values by column id.
Examples
$filterValues = {} | Name | Info | ||||
|---|---|---|---|---|---|
| First Name | Last Name | Age to | Status | Visits | Profile Progress |
| Cora | Moore | 54 | relationship | 52 | 29 |
| Ilene | Goodwin | 37 | complicated | 29 | 63 |
| Edgar | Considine | 25 | relationship | 97 | 96 |
| Meredith | Mayert | 18 | single | 52 | 64 |
| Sarai | Kovacek | 65 | complicated | 40 | 82 |
| Alfredo | Friesen | 64 | complicated | 63 | 82 |
| Tiffany | Botsford | 35 | single | 3 | 55 |
| Hazel | Herman | 48 | single | 49 | 58 |
| Russell | Hoppe | 42 | relationship | 97 | 37 |
| Jeff | King | 56 | complicated | 2 | 57 |
| Amiya | Prosacco | 33 | single | 36 | 93 |
| Ernie | Okuneva | 60 | single | 97 | 77 |
| Oceane | Boehm | 29 | single | 22 | 36 |
| Rita | Flatley | 22 | relationship | 81 | 17 |
| Lamar | Wintheiser | 45 | complicated | 30 | 83 |
| Kyle | Flatley | 19 | single | 54 | 36 |
| Mamie | Schamberger-Kunze | 28 | single | 61 | 75 |
| Horace | Hickle | 40 | relationship | 54 | 26 |
| Florence | Zieme | 44 | single | 55 | 64 |
| Leland | Mitchell | 32 | complicated | 24 | 7 |
| Antonia | McLaughlin | 55 | single | 63 | 16 |
| Manuel | Nitzsche | 65 | relationship | 77 | 18 |
| Nellie | Schulist | 27 | relationship | 15 | 41 |
| Pat | Miller | 64 | complicated | 38 | 50 |
| Ricky | Kessler | 24 | complicated | 20 | 84 |
| Kip | Ratke | 30 | single | 0 | 55 |
| Lyle | Greenholt | 38 | complicated | 57 | 99 |
| Jaquelin | Sanford | 26 | single | 13 | 21 |
| Genevieve | Schroeder | 39 | relationship | 45 | 2 |
| Shawna | Cole | 35 | single | 92 | 43 |