Referencing Row Data in Expressions

Summary

  • AdaptableQL can reference data that is in the data source but is not a Column
  • This is done via the FIELD expression function
  • Fields are defined in Expression Options

Expressions typically directly reference data which is stored in an Adaptable Column.

However Expressions can also operate on row data which is not contained in a Column.

Note

The data for the field needs to be in the underlying data source but its not represented by an AG Grid Column

This is done via 2 stage process:

  • define the Fields in the fields property of Expression Options (so they are available in the UI)
  • reference the Fields in Expressions by using the FIELD keyword

Defining Fields

Fields are defined by being listed in the fields property of Expression Options.

This means the Fields are now available in the AdapTableQL UI and can be used similarly to Columns:

  • The Query Builder allows users to select Fields when creating Conditions - similar to Columns
  • The Expression Editor lists all defined Fields which are draggable into the Editor

Hint

  • Expressions containing Fields that have not been defined in Expression Options are still perfectly valid
  • However the Expression cannot be edited in Query Builder

The Fields can be provided either as a list or via a function which returns a list.

fields

Default: null
Non-column row data to be used in AdapTableQL Expressions

Referencing Fields

Fields are referenced in Expressions using the FIELD keyword.

This has a single parameter which is the name of the data field:

 FIELD('forks_count')

Note

When using Fields you have to use the FIELD keyword explicitly - the square brackets shortcut is not available

Nested Row Data

If the row data is nested inside another object, you need to use the full reference using the '.' operator.

For instance if a multipliers object contained a watchers_multiplier property, it should be referenced:

 FIELD('multipliers.watchers_multiplier')
Expressions using Row Data
Fork
  • This example shows how to create AdapTableQL Expressions that reference row data, rather than Columns
  • We added 3 additional fields to our typical row data: forks_count, stars_multiplier & watchers_multiplier (the latter 2 inside a nested multipliers object)
  • We then defined those fields in the fields property of Expression Options (so they are available in the UI)
  • We wrote Expressions that reference this row data using the FIELD property (even though neither are Columns):
    • 2 Calculated Columns - Full Stars and Full Watchers that multiply Github Stars and Github Watchers with their respective multiplier values
    • A Grid Filter with the simple Expression: FIELD('forks_count') > 5000
  • We also applied a Custom Sort to Github Stars (that multiplies by stars_multiplier) - which is why the Column doesn't sort numerically