logo

addColumnFilters

addColumnFilters filters table rows by specific column values.

Options

Information:
Options passed into addColumnFilters.
const table = createTable(data, {
  colFilter: addColumnFilters({ ... }),
});
const table = createTable(data, {
  colFilter: addColumnFilters({ ... }),
});

serverSide?: boolean

If true, filtering will not change $rows. Control filtering by updating $data and use plugin state to drive your fetch.

Defaults to false.

Column Options

Information:
Options passed into column definitions.
const columns = table.createColumns([
  table.column({
    header: 'Name',
    accessor: 'name',
    plugins: {
      colFilter: { ... },
    },
  }),
]);
const columns = table.createColumns([
  table.column({
    header: 'Name',
    accessor: 'name',
    plugins: {
      colFilter: { ... },
    },
  }),
]);

fn: ({ filterValue, value }) => boolean

Defines filter behavior for the column. Return true to keep the row.

render?: (renderProps) => RenderConfig

Renders a control on HeaderCell->props.[pluginName].render. renderProps extends TableState and includes:

  • id: string
  • filterValue: Writable<any>
  • values: Readable<any[]>
  • preFilteredValues: Readable<any[]>
  • preFilteredRows: Readable<BodyRow[]>

initialFilterValue?: any

Initial filter value.

Prop Set

Information:
Extensions to the view model. Subscribe to .props() on table components.
{#each $headerRows as headerRow (headerRow.id)}
  <Subscribe rowProps={headerRow.props()} let:rowProps>
    {rowProps.colFilter}
    {#each headerRow.cells as cell (cell.id)}
      <Subscribe props={cell.props()} let:props>
        {props.colFilter}
      </Subscribe>
    {/each}
  </Subscribe>
{/each}
{#each $headerRows as headerRow (headerRow.id)}
  <Subscribe rowProps={headerRow.props()} let:rowProps>
    {rowProps.colFilter}
    {#each headerRow.cells as cell (cell.id)}
      <Subscribe props={cell.props()} let:props>
        {props.colFilter}
      </Subscribe>
    {/each}
  </Subscribe>
{/each}

Plugin State

Information:
State provided by addColumnFilters.
const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;
const { headerRows, rows, pluginStates } = table.createViewModel(columns);
const { ... } = pluginStates.colFilter;

preFilteredRows: Readable<BodyRow<Item>[]>

Rows before filtering.

filterValues: Writable<Record<Id, FilterValue>>

Active filter values by column id.

Examples

$filterValues = {}
Name Info
First Name
Last Name
Age
to
Status
Visits
Profile Progress
LorenzBartell22complicated890
LoyalTurner-Batz48relationship11100
TimothyBradtke46complicated8822
DiannaBoehm62relationship9863
MalikaSkiles38relationship1196
HerthaWiegand19single8745
ThadNitzsche46single4375
EmilioTowne65relationship37100
BradfordWalter50complicated798
TomasBogisich59relationship2256
GiovaniVeum60complicated1324
VenaStehr-Romaguera24single8566
ConstanceSimonis-Beahan42relationship827
LolaKohler55complicated7764
FerminStroman25single1399
ShannyHayes28relationship3298
PatLuettgen36single1411
SonnyHickle39relationship4269
ConstanceO'Conner18single8594
DimitriGraham49complicated7279
MiracleHauck37single6082
VadaBogisich49complicated4076
JaylanHaley58single5230
DemarioVonRueden57relationship1940
AlexandraWiegand57relationship1952
JeanetteBruen37single8681
ChayaNader54complicated780
MaraDavis35relationship7886
GregorioSauer40single9699
DianaMurazik41single4144