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
EileenTremblay24complicated205
MariaMcLaughlin19complicated5626
IgnatiusSauer32single2239
StevieBosco49relationship5636
EloiseStoltenberg46complicated2828
KellyHettinger51single7569
EuniceKilback20relationship2498
MittieBergstrom21relationship2015
CierraLindgren51single2693
RussellVolkman48relationship3655
OwenLittle22single4993
DellaTrantow48relationship1441
MaceyO'Keefe63relationship437
KamrynGibson51relationship9034
PatrickSpencer52relationship3673
SherrySchmeler64relationship3720
MaximilliaSkiles59single921
EarnestBoyer58relationship5478
EvelynSpencer20relationship575
WilbertBlanda40complicated689
KristyKertzmann41complicated5862
DwightFadel29relationship480
MaxinePowlowski36complicated444
DarylJenkins62single2714
AllieFranecki51single629
OwenStiedemann26single834
MattBruen42relationship8893
EzekielJohns53complicated4850
MarcellaFriesen62complicated8751
ChadBins47single4968