Custom Column Filters
Summary
- Developers are able to provide their own bespoke Column Filter operators - boolean Custom Expression Functions
- These are defined via
customStandardFunctionsin 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:
operands | Number | Appears as |
|---|---|---|
[['number']] | 1 | An operator with no input (Column subject only) |
[['text', 'number']] | 2 | An 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
- See Custom Standard Functions for the full anatomy of a custom Expression Function
- See System Filters to control (per Module or per Column) which operators are available
- 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; returnstruewhen the value exceeds 10,000LONGER_THAN(2 operands) - a one-input operator (labelled Longer Than,>nicon) offered on text Columns; returnstruewhen the text is longer than the supplied number of characters
- Both are pre-applied as Column Filters:
IS_POPULAR([github_stars])andLONGER_THAN([name], 5)
- Open the
Github Starsfilter dropdown and see the Popular operator (star icon, no input) alongside the System operators - Open the
Namefilter dropdown, choose Longer Than and enter a number to filter by text length — the>nicon makes it easy to spot in the Filter Bar
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