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
MathildeHeathcote60single9100
DayanaLehner25complicated3752
EmersonRaynor26single326
BrooklynOberbrunner59single1897
KristaKovacek41complicated6248
CreolaSchamberger40relationship2430
KatrineZulauf42relationship2572
BabyRosenbaum53complicated1854
VicenteMayert37single383
MagdalenRatke43relationship7376
VernieHerman55single4194
MerrittMills44relationship9488
GianniShields40single6531
MichaleSchmeler58relationship3981
AlexandraBlanda42complicated9815
AdelleHilll46single10020
GlendaJaskolski30complicated5365
AmiraVolkman24complicated8985
JoyceSmith65single9775
CristinaGislason43single3678
WalkerFeest62relationship1950
AsaDavis48complicated210
JasonKoepp43relationship8964
MarcellaGleichner47relationship983
FelicityHeathcote27complicated9531
EasterFadel44single6466
JaysonWitting40complicated8515
BryanaBrekke48relationship9647
KaydenWuckert39relationship5231
AngelWalsh46single9286