logo

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 = 
NameInfo
First NameLast NameAgeStatusVisitsProfile Progress
WilliamCollier63single6120
JuniorStehr65single7514
AmelieJast33single9811
LaneyBuckridge45relationship8274
CliffordOrtiz49single3967
LavernaMoore27complicated1733
ClemensWyman24complicated3395
ClarkBarton48single6116
AlbaHarber40single5649
AshleySpencer28single6291
ChadBayer64relationship665
MelodyLindgren57complicated776
LucileHomenick41complicated32
JerodLarkin46relationship4122
FabianMcDermott52relationship1225
JaniceGoodwin41relationship5913
JakobJohnson18complicated7238
OletaHills-Leuschke65relationship253
NorbertoYost65relationship4798
HazelTurner44single1136
HendersonNicolas44relationship9043
HermanWiegand39relationship3020
ElwynChamplin33single1391
CecileMills56relationship1895
VirgilGoyette38relationship3579
DomenickZboncak57relationship1158
MireilleJacobi40complicated054
MelvinVandervort20relationship2375
MeggieRempel42relationship8674
RylanTerry55relationship9756