Column Filters

View as Markdown

Summary

  • AdapTable offers very rich, powerful column filtering capability
  • Each Column Filter can contain multiple conditions (using Expressions) together with AND / OR functionality
  • These can either be Expression Functions (provided by AdapTable) or Custom Functions (defined by users)
  • Column Filters complement (and can be used together with) the Grid Filter
  • There are 2 Custom Filter Components provided:
    • Filter Bar - between Column Header and first row of Grid
    • Filter Form - available from Column Menu, Filter Tool Panel and other places

Column Filtering in AdapTable is extremely intuitive, rich and extensible.

Note

Column Filters complement, and work in conjunction, with the Grid Filter; both can be active at the same time

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

Hint

Filtering is a constant operation - Column Filters will be continually re-applied as data in the grid changes

Filter Components

AdapTable offers 2 Filter Components to enable users to perform run-time Column Filtering:

  • Filter Form, a rich, configurable component that provides full filtering capability
  • Filter Bar (underneath Column Header), designed to facilitate instant filtering (including wildcards)

Both components offer full, advanced, filtering capability including:

  • displaying all available Column Filter Expression Functions (for that Column) and any inputs required
  • support for Custom Expression Functions
  • dedicated UI for IN (and NotIn) Expression Function enabling multiple values to be displayed and selected
  • automatically updating the Layout (and Layout State) as Column Filters are applied

Caution

  • The Filter Form and Filter Bar replace AG Grid's Filter Form and Floating Filter respectively
  • They are the only instances where AdapTable provides alternative, not complementary, functionality to AG Grid

Other Filter Components

In addition to the 2 Filter Components, run-time users can create and edit Column Filters in the Layout Wizard.

AdapTable also provides 4 other filter-related components.

These allow Users to clear or suspend some or all current Column Filters and are available as:

Expressions

Column Filters are essentially a simple combination of 2 objects:

Note

  • The Expression is always limited to a single column
  • Use the Grid Filter to create Expressions that reference, or compare, multiple columns
Filters
Fork
  • This example shows 5 Column Filters applied across 2 Layouts:
  • The Filtered Layout contains 3 Filters:
    • Language is 'TypeScript' or 'JavaScript' - using the IN function (similar to SQL): [language] IN ("TypeScript", "JavaScript")
    • Name ends with '.js' - using the ENDS_WITH function: ENDS_WITH([name], ".js")
    • Published since 2016 - using a date comparison: [pushed_at] > DATE("2016-01-01")
  • The MIT Layout contains 2 Filters:
    • License equals 'MIT License' - using =: [license] = "MIT License"
    • Github Stars between 20k and 90k - using >= and <=: [github_stars] >= 20000 AND [github_stars] <= 90000
  • We have also chosen to display the Column Filter Toolbar in the Dashboard, and set the Clear and Suspend Buttons to be displayed
Try It Out
  • Switch between Layouts and see that the different Layouts display different Filters
  • Change the Column Filter for the Language Column to include 'JavaScript' and 'HTML' projects
Loading demo…

Custom Filters

As seen above, most Column Filters use the built-in Expression Functions that AdapTable provides.

However Column Filters can also leverage bespoke, user-defined Custom Expression Functions - for instance to wrap a lookup over many values in a single, reusable, named function.

Combining Clauses with AND / OR

A single Column Filter Expression can contain multiple clauses if required.

These are combined using the AND and OR keywords (with parentheses for grouping).

Hint

The same AND / OR logic is available in Alerts, Conditional Styling and Flashing Cells

Use AND when all clauses must be true for a row to pass, and OR when any clause passing is enough.

Note

  • Expressions with multiple clauses are created in the Filter Form
  • The Filter Bar is designed for instant, single-clause filtering
Filters using AND / OR
Fork
  • This example shows 2 Column Filters, each combining two clauses with a different operator:
    • Name - CONTAINS 'e' AND ENDS_WITH 's': CONTAINS([name], "e") AND ENDS_WITH([name], "s")
    • Github Stars - less than 10,000 OR greater than 20,000: [github_stars] < 10000 OR [github_stars] > 20000
Loading demo…

Formatted Cells

AdapTableQL evaluates the Expression based on the underlying value in the Cell.

Caution

AdapTable will evaluate Filters using the raw value of the cell (rather than the display value)

If a column uses an AG Grid Cell Component, an AG Grid Value Formatter or an Adaptable Display Format, the filter is evaluated using the cell's underlying (i.e. raw) value.

AdapTable will not evaluate based on what is actually displayed in the Grid.

Note

Using Column Filters

Run-time users are able to create and edit Column Filters using all the available Filter Components.

In addition, users can leverage the Column Filter Toolbar, Tool Panel, Status Bar Panel and Settings Panel to clear, suspend or share some or all current Filters.

Column Filters are persisted in the Layout section of the Adaptable State and then automatically re-applied on application re-start when the relevant Layout is loaded.

Creating Filter via Context Menu

The Context Menu has a "Filter on Cell Value(s)" option (available only if the selected cells are in one Column).

This will create a new Equals Filter based on the value of what is the currently selected cell.

Note

If there is more than one distinct cell value in the Column's selection range, an IN filter is created instead

Seeing Current Filters

AdapTable shows users the currently applied Column Filters in AG Grid in the Filter Toolbar, Tool Panel, Status Bar and Settings Panel .

Note

Each provides a description of the Expression and Column together with a Clear button

Hint

  • AG Grid indicates which Columns are filtered in the Column header and Filter Tool Panel (in Sidebar)
  • AdapTable changes the style of the Column Header for any currently filtered columns

Suspending Filters

Column Filters - like all AdapTable Objects - can be suspended.

When a Column Filter is suspended, the Filter Bar and Filter Form show details of, but do not run, the associated Expression.

Note

You need either to un-Suspend or Clear a suspended Filter before setting a new Filter for that Column

Filtering Dynamic Columns

Columns created dynamically by AG Grid can be filtered (click the links to see demos):

Configuring Filters

Developers are able to configure Filters at design time as follows:

Find Out More

FAQ

Can I filter Row Group, Pivot or Tree columns? Yes. See Filtering Dynamic Columns — Row Grouped, Pivot Result and Tree Grid Key Columns all use the AdapTable Filter Form. The Tree column defaults to an IN Filter with a tree structure.

Why doesn't the Column Filter work with my AG Grid Cell Component? AdapTable always filters on a cell's underlying (or raw) value than the display value. This is because the column could be numeric but the cell could display a string (e.g. '£24K'), so to ensure filters always work they are always applied on the underlying value.

Can we evaluate Column Filters on the server? Yes, via the evaluateAdaptableQLExternally property in Expression Options (see Server Evaluation for more details)

Caution

This option is only available if you are using the AG Grid Client Side Row Model.

Can we include AND or OR logic in a Column Filter Yes, this is available in Column Filters - and also in the Grid Filter

Why don't my Filters get applied when the data changes in my grid? AdapTable re-applies active Column Filters and the Grid Filter when cell values change — both user edits and ticking data. There is no option to skip ticking updates. If nothing changes, check that a Filter is actually active on the Column that updated.

The filter for string columns defaults to CONTAINS. Can we change this to STARTS_WITH? Yes. Use the defaultTextColumnFilter property in Column Filter Options. Similar settings allow you to change the defaults for numeric and date columns.

Are we only able to set the Filter for the Current Layout? If you are using the Filter Bar or Filter Form to create Filters, then they do, indeed, only update the Current Layout. However you can use the Layout Wizard to set Column Filters for any Layout (and not just the Current one)