Custom Column Filters

View as Markdown

Summary

  • Developers are able to provide their own bespoke Column Filter operators - boolean Custom Expression Functions
  • These are defined via customStandardFunctions in Expression Options
  • Custom Expression functions will automatically appear in the operator dropdown for the relevant Columns

Developers can provide bespoke custom filter operators in addition to the AdapTable-provided System Filters.

This is done by registering a custom boolean Expression Function - in the customStandardFunctions section of Expression Options - and AdapTable will make it available.

Custom functions can be provided with operands, the number of which determines how the function appears in the Column Filter:

operandsNumberAppears as
[['number']]1An operator with no input (Column subject only)
[['text', 'number']]2An operator with one input (Column + value)

Optional label and icon appear in the Column Filter / Filter Bar operator picker — the same presentation fields used by System operators. An icon can be a named AdapTable icon ({ name: 'star' }), a short text glyph ({ text: '>n' }), or a custom image / element.

Note

  • Only boolean functions with 1 or 2 operands appear in the Column Filter (and Query Builder)
  • Functions with 0 or 3+ operands are available in the Expression Editor only

Find Out More

Custom Filters
Fork
  • This demo registers 2 custom boolean Expression Functions which become Column Filter operators:
    • IS_POPULAR (1 operand) - a no-input operator (labelled Popular, star icon) offered on numeric Columns; returns true when the value exceeds 10,000
    • LONGER_THAN (2 operands) - a one-input operator (labelled Longer Than, >n icon) offered on text Columns; returns true when the text is longer than the supplied number of characters
  • Both are pre-applied as Column Filters: IS_POPULAR([github_stars]) and LONGER_THAN([name], 5)
Try It Out
  • Open the Github Stars filter dropdown and see the Popular operator (star icon, no input) alongside the System operators
  • Open the Name filter dropdown, choose Longer Than and enter a number to filter by text length — the >n icon makes it easy to spot in the Filter Bar
Loading demo…

Users can create as many custom (and System) Column Filters as required.

AdapTable will automatically update AG Grid so that only rows which match all Filters are displayed.

Overriding a System Operator

You can also replace a System operator with your own implementation.

To do this, register a custom function using extends to inherit the System function's label, icon and operands while supplying your own handler.

Find Out More

See Custom Standard Functions for how to override a System Expression Function via extends