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 |
| Cooper | Moore | 54 | relationship | 52 | 29 |
| Imani | Goodwin | 37 | complicated | 29 | 63 |
| Earl | Considine | 25 | relationship | 97 | 96 |
| Mildred | Mayert | 18 | single | 52 | 64 |
| Santa | Kovacek | 65 | complicated | 40 | 82 |
| Alfred | Friesen | 64 | complicated | 63 | 82 |
| Timmothy | Botsford | 35 | single | 3 | 55 |
| Gwendolyn | Herman | 48 | single | 49 | 58 |
| Ryan | Hoppe | 42 | relationship | 97 | 37 |
| Javier | King | 56 | complicated | 2 | 57 |
| Amani | Prosacco | 33 | single | 36 | 93 |
| Esmeralda | Okuneva | 60 | single | 97 | 77 |
| Noemie | Boehm | 29 | single | 22 | 36 |
| Rita | Flatley | 22 | relationship | 81 | 17 |
| Kurtis | Wintheiser | 45 | complicated | 30 | 83 |
| Lamar | Flatley | 19 | single | 54 | 36 |
| Marcia | Schamberger-Kunze | 28 | single | 61 | 75 |
| Hector | Hickle | 40 | relationship | 54 | 26 |
| Fannie | Zieme | 44 | single | 55 | 64 |
| Lawson | Mitchell | 32 | complicated | 24 | 7 |
| Antoinette | McLaughlin | 55 | single | 63 | 16 |
| Marcos | Nitzsche | 65 | relationship | 77 | 18 |
| Napoleon | Schulist | 27 | relationship | 15 | 41 |
| Paul | Miller | 64 | complicated | 38 | 50 |
| Ricky | Kessler | 24 | complicated | 20 | 84 |
| Khalil | Ratke | 30 | single | 0 | 55 |
| Mack | Greenholt | 38 | complicated | 57 | 99 |
| Janick | Sanford | 26 | single | 13 | 21 |
| Freda | Schroeder | 39 | relationship | 45 | 2 |
| Sheila | Cole | 35 | single | 92 | 43 |