AdapTableQL Fields

In addition to accessing columns, AQL also supports the use of fields (e.g. FIELD("name"), FIELD("user.firstName")).

A field is a property in your row data that is not necessarily mapped to a column.

Note

When the property is an object, you can access nested properties using dot notation.

'FIELD("user.firstName"), FIELD("user.lastName")';

In a calculated column, this will look like this:

const availableColumns = {
  fullName: {
    expression: 'FIELD("user.firstName") + " " + FIELD("user.lastName")',
    dataType: 'text',
    width: 300,
  },
};
Using property access via the FIELD method in AQL
Fork
  • In this example, we have provided a FIELD called language (which is not a Column)
  • The expresion for the Description Calculated Column references this field: '[name] + " - written in " + FIELD("language")'

Fields as entities

In any AQL expression, the FIELD function can target any field/property in the row data.

However, in the UI, the user won't have access to those fields in the expression editor or the query builder unless they are defined as entities in the state.

In order to make fields available for drag-and-drop operations or for selection the in the query builder, make sure they are declared in the state.

Defining fields as entities in the state
const state: AdaptableUserState = {
  globalEntities: {
    availableColumns: { ... },
    fields: {
      'user.firstName': { // use the dot notation for nested properties
        dataType: 'text',
        label: 'First Name',
      },
      'age': {
        dataType: 'number',
        label: 'Age',
      },
    }
  }
}

Hint

To add new fields to the state, use controlled state and update your state with the new fields