Defining Column Filters

Summary

  • Column Filters are defined inside a Layout
  • They can be defined in both Table and Pivot Layouts

Column Filters can be provided at design-time in given Layouts via Layout Initial State.

This can include Column Filters which use System Predicates and those which use Custom Predicates.

Find Out More

Developer Guide

Defining Columns Filters in a Layout

Column Filters are provided in a Layout as follows:

// Provide 3 Column Filters
// a. In (System Predicate) on currency Column for 'USD' and 'EUR'
// b. GreaterThan (System Predicate) on price Column
// c. 'post-takeover' (Custom Predicate) on orderDate Column
// The Custom Predicate is defined in Predicate Options
const adaptableOptions: AdaptableOptions = {
  const initialState: InitialState = {
    Layout:{
      CurrentLayout: 'Filtered Layout',
      Layouts: {
        Name: 'Filtered Layout',
        TableColumns: ['currency', 'orderData', 'github_watchers', 'price'],
        ColumnFilters: [
        {
          ColumnId: 'currency',
          Predicates: [
          {
            PredicateId: 'In', 
            Inputs: ['USD', 'EUR']
          }]
        },
        {
          ColumnId: 'price',
          Predicates: [
            {
              PredicateId: 'GreaterThan', 
              Inputs: ['500']
            }
          ],
        },
        {
          ColumnId: 'orderDate',
          Predicates: [
            { 
              PredicateId: 'post_takeover' 
            }
          ],
        },
      ],   
    }
  },
  predicateOptions: {
    customPredicateDefs: [
      {
        id: 'post_takeover',
        label: 'Post Takeover',
        columnScope: { DataTypes: ['date'] },
        moduleScope: ['columnFilter', 'alert'],
        handler(params: PredicateDefHandlerContext) {
          return (params.value as Date) > new Date('2019-09-21');
        },
      },
    ],
  }
};
1
Provide a ColumnFilters section

Create a ColumnFilters property inside a Layout

This is an array with one item for each Column Filter to be provided

2
Provide Column Id

Supply the ColumnId for each Filter.

3
Provide Predicate

Specify which Predicate to use:

  • The PredicateId property must always be supplied
  • Provide Inputs if required by the chosen Predicate
4
Define any Column Filters using Custom Predicates

A Column Filter can also reference a user-provided Custom Predicate.

Again, provide the ColumnId and the PredicateId property (and any inputs).

Caution

The Column in the Filter must be appropriate to the columnScope defined in the Predicate

5
Define Custom Predicate in Adaptable Options (if using Custom Filters)

Create the Predicate in customPredicateDefs property in Predicate Options.

Make sure that the moduleScope includes 'columnFilter' if you want to use it in a Column Filter and provide the appropriate columnScope.

AdapTableQL uses the handler function to evaluate and apply the filter.

Find Out More