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 the table’s 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. Read current.props on table components. The lists below are generated from the plugin's TypeScript prop-set type, so they match the published package exactly.

BodyCell props cell.current.props.tableFilter

matches: boolean
True if this cell matches the current filter.

Interactions

  • Hidden columns are excluded from the search by default. Set includeHiddenColumns: true to search their values while they are hidden.
  • With addSubRows, a parent row is kept when any descendant matches, and only the matching descendants are shown under it.

Plugin State

Information:
State provided by addTableFilter.
const vm = table.createViewModel(columns)
const { pluginStates } = vm
const { filterValue } = pluginStates.filter
const vm = table.createViewModel(columns)
const { pluginStates } = vm
const { filterValue } = pluginStates.filter

filterValue: Box<string>

The current filter text. Bind an input to it directly:

<input bind:value={filterValue.current} placeholder="Search rows..." />
<input bind:value={filterValue.current} placeholder="Search rows..." />

preFilteredRows: ReadonlyBox<BodyRow<Item>[]>

The rows before filtering was applied.

Examples

filterValue.current = 
NameInfo
First NameLast NameAgeStatusVisitsProfile Progress
EdgarTremblay24complicated205
MadgeMcLaughlin19complicated5626
JanessaSauer32single2239
TerranceBosco49relationship5636
EarnestineStoltenberg46complicated2828
KatherineHettinger51single7569
FaithKilback20relationship2498
NathanialBergstrom21relationship2015
CharleneLindgren51single2693
RoscoeVolkman48relationship3655
OliveLittle22single4993
CorrineTrantow48relationship1441
MadisenO'Keefe63relationship437
KrisGibson51relationship9034
NobleSpencer52relationship3673
ShanaSchmeler64relationship3720
MossieSkiles59single921
DrakeBoyer58relationship5478
EveretteSpencer20relationship575
WilfredoBlanda40complicated689
KiaraKertzmann41complicated5862
DonnieFadel29relationship480
MariahPowlowski36complicated444
DashawnJenkins62single2714
AmirFranecki51single629
NicolasStiedemann26single834
MarianoBruen42relationship8893
GuadalupeJohns53complicated4850
MilanFriesen62complicated8751
CarrieBins47single4968