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
AutumnBednar28single4199
MistyMarquardt53complicated6942
SkyeSchmidt55relationship4010
ErinWeissnat42single9971
DameonMacejkovic33relationship9056
JorgeBrakus60single3025
JonathanSpencer36relationship8921
AndreWunsch56relationship6235
StephanieEbert61relationship3247
ClotildeHintz63single810
KaitlynProsacco24single5054
KristyTowne56single1883
AlleneVonRueden41relationship448
AlishaBernier21relationship2297
DarrylLueilwitz31relationship8338
WilbertMante50complicated2934
FrancisKozey53relationship498
AbelBechtelar33single8271
CristalToy20relationship8512
LilaKihn54complicated769
JamalUpton53complicated7373
AiyanaEbert59complicated9457
CheyanneToy60relationship9359
DemarcoMarvin58relationship8025
GwenSanford20single4613
DinoBarton28relationship5876
KailynRau59single6595
FabiolaKuvalis40single491
CarsonChamplin27single1071
LauryHerzog37single150