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
KathryneGreenfelder42relationship9090
CoralieKiehn19relationship4665
MarianaBailey44relationship2641
MatildeCrona44relationship7830
GilbertWolf50complicated9185
AudreyLynch35complicated2241
DomingoKoch59relationship5928
JackelineDouglas42complicated848
MelisaPollich51complicated3767
KiarraKilback20relationship2498
MateoReilly40relationship606
CloydBradtke24single5518
MarisaQuigley30single9384
JaydaRodriguez49complicated9264
KavonDicki52single7998
KarinaKuhn62complicated7948
CyrilBins60complicated6414
AmaniRenner49complicated4827
VernBernier20complicated896
RodolfoGibson51relationship9034
SalvatoreRobel25single7084
FlossieConn33relationship4288
ShanelleWitting35single2024
VirgieKub31relationship8488
CrystalStanton33complicated2843
AustinLesch55single2397
EvelynProhaska58single45
EllisCrist64relationship5083
JavonteTorp39complicated67
ArchibaldKertzmann41complicated5862