Adaptable

#AdaptableQL Fields

Besides columns, AdaptableQL expressions can read fields — properties of your row data that are not necessarily mapped to a column. Use the FIELD function with the property name:

FIELD("preferredLanguage")

For nested objects, use dot notation:

FIELD("address.city")

In a calculated column, this looks like:

const availableColumns: Record<string, AdaptableColumnConfig> = {
  location: {
    label: 'Location',
    dataType: 'text',
    expression: 'CONCAT(FIELD("address.city"), ", ", FIELD("address.country"))',
  },
};
Note

FIELD reads the row data directly, by property path. Columns are referenced with [columnId] and go through the column's field, valueGetter or expression. When a value is available as a column, prefer the column reference.

#Declaring fields

FIELD can read any property of the row when an expression is evaluated. However, the expression editors only know about the fields you declare in globalEntities.fields. Declared fields are listed next to the columns in the editor, offered in completions and in the query builder. A FIELD("…") reference to a field that isn't declared is flagged as an error in the editors.

globalEntities.fields is keyed by the property path — use dot notation for nested properties — and each field needs a label and a dataType:

Declaring fields in globalEntities
const defaultState: AdaptableUserState = {
  globalEntities: {
    availableColumns: { /* ... */ },
    fields: {
      preferredLanguage: { label: 'Language', dataType: 'text' },
      'address.city': { label: 'City', dataType: 'text' },
      'address.country': { label: 'Country', dataType: 'text' },
    },
  },
  view: { currentViewId: 'default', views: [{ id: 'default', label: 'Developers' }] },
};
#
Reading fields with FIELD()

preferredLanguage and the nested address object are not columns. The Description calculated column uses CONCAT([firstName], " writes ", FIELD("preferredLanguage")), and Location uses CONCAT(FIELD("address.city"), ", ", FIELD("address.country")).

Click the calculated column button in the dashboard and create a new column: the declared fields are listed in the expression editor.

open
loading demo…
Tip

To add fields at runtime, use controlled state (see State) and update globalEntities.fields.