Custom Column Filters

Summary

  • Column Filters can use bespoke Custom Predicates in addition to the System Predicates that AdapTable provides

Most Column Filters use System Predicates which are shipped with AdapTable.

However Column Filters can also leverage bespoke, user-defined Custom Predicates.

Find Out More

  • See Custom Predicate Definitions to learn how Developers can provide design-time Custom Predicates
  • Once defined, these will be displayed in in the Filter Components and available to be used in Filters
Custom Filters
Fork
  • This example shows a Layout with 3 Column Filters each using a Custom Predicate:
    • Github Stars uses the Popular Predicate - which only shows values with more than 10,000 stars
    • Language uses the Scripting Predicate - which limits values to 'JavaScript' or 'TypeScript' (we also created a Conditional Style using this Predicate)
    • Created has the Last Ten Years Predicate applied - which filters to dates in previous 10 - and has a Scope of all Date columns
Try It Out
  • Clear the Scripting Filter in the Language column and note how the cells with 'HTML' are not formatted (since they do not pass the Predicate which is still being used for Formatting)

Users can create as many Custom (and System) Column Filters as required and AdapTable will automatically update AG Grid so that only rows which match all Filters will be displayed.

Predicate Inputs

Custom Filters, like all Predicates, are able to accept inputs - so they can be given a dynamic argument.

Custom Filters with Inputs
Fork
  • This demo creates a Custom Filters that receives an input
  • Long String has a columnScope of String columns, and receives a number input which verifies if the string is big or not
Try It Out
  • Create a Column Filter on the Language Column using the Long String Custom Predicate and an input of 5: note that the 2 rows with HTML will be filtered out

Custom Time Filters

Custom Filters are useful when you want to filter a Date Colum using only Time.

AdapTable provides a large number of System Filters but they all operate on a Date, not the Time portion only.

Hint

This is particularly useful if you have a "Day Activity Grid" which just displays entries for a single day

Custom Filters using Time
Fork
  • This demo creates 2 Custom Filters that use Time (both have columnScope of the Pushed column which we have changed to just show Times for today):
    • Overnight returns true if the time in the Column is between midnight and the start of the day (9am)
    • Recent receives a numeric input and returns true if the value is within the inputted number of hours
  • Note: we also removed some Date System Predicates to make it easier to see the 2 Custom Predicates
Try It Out
  • Run Column Filter on Pushed Column using Midnight Custom Predicate and note only values before 9am appear
  • Run Column Filter on Pushed Column using Recent Custom Predicate and an input of 5 and note: only rows with a value in last 5 hours are displayed

Referencing Other Columns

The handler property used when evaluating Custom Predicates is given the current row node in its context.

This allows you to create Custom Filters that reference other Columns in the Row as part of the evaluation.

Custom Filters accessing Other Columns
Fork
  • This demo creates 2 Custom Filters that reference other Columns in the Row for its evaluation:
    • Big Stars returns true for Github Stars Column if it is greater than 10,000 and Github Watchers is over 200
    • Success returns true for Closed Issues Column if it is greater than the Closed PRs Column

Overriding System Filters

In addition to providing new Custom Filters, developers can provide Custom Filters which override the System Predicates shipped by AdapTable.

Hint

Make sure that the Custom Predicate has the same id as the System Predicate it replaces

This replaces the implementation for the System Filter provided by AdapTable with the custom behaviour.

Note

  • The Custom Predicate is placed in the same position in the Filter List as the System Predicate it replaces
  • The icon which is displayed in the Filter Predicate dropdown is that of the overridden System Predicate

Find Out More

See Overriding System Predicates for more information and a full, explanatory, demo

Providing AdapTable with Custom Filters

(Recorded with AdapTable v16.2)