Calculated Column Technical Reference

Summary

  • Calculated Column Initial Adaptable State enables Calculated Columns to be defined at design time
  • Calculated Column API Section of Adaptable API contains functions relating to Calculated Columns

Calculated Column State

The Calculated Column section of Adaptable State contains an array of CalculatedColumn objects:

PropertyDescription
CalculatedColumnsCollection of Calculated Columns

Calculated Column

The Calculated Column is defined as follows:

PropertyDescription
CalculatedColumnSettingsAdditional optional properties for Column (e.g. filterable, resizable)
ColumnIdName of Calculated Column
FriendlyNameName to be used in Column Header; if blank ColumnId is used
QueryScalar/AggregatedScalar Query used by AdapTableQL to evaluate Column's value
IsReadOnlySets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full')

Calculated Column Settings

The Calculated Column Settings property contains additional options for the Calculated Column:

PropertyDescriptionDefault
ShowToolTipShow underlying Expression as ToolTip when hovering over a cellfalse

But it also inherits from SpecialColumnSettings which is defined as follows:

PropertyDescriptionDefault
AggregatableWhether Column can be used in an aggregation when groupingfalse
ColumnTypesCustom column types added to AG Grid Column Types when object is created
DataTypeExpression's return value DataType, only mandatory property
FilterableWhether Column is filterablefalse
GroupableWhether Column can be groupedfalse
HeaderToolTipTooltip to show in the Column Header (not cells)
PivotableWhether Column can be used when grid is in pivot modefalse
ResizableWhether Column can be resized (by dragging column header edges)false
SortableWhether Column is sortablefalse
SuppressMenuWhether if no menu should be shown for this Column header.false
SuppressMovableWhether if this Column should be movable via draggingfalse
WidthPreferred (pixel) Column Width; if unset, calculated dynamically by AG Grid

Calculated Column Changed Event

The Calculated Column Changed Event fires whenever the Calculated Column State changes.

It provides full information about the new Calculated Column and what triggered the change.

Calculated ColumnChangedInfo

The event comprises a single CalculatedColumnChangeInfo object which contains details about what action triggered the change and the associated Caluculated Column.

PropertyDescription
actionNameWhat caused CalculatedColumn State to change (i.e. Add, Edit, Delete)
calculatedColumnCalculated Column that has been added, edited or deleted
calculatedColumnExpressionASTAST for Current Calculated Column Expression
adaptableContextCustom application Context provided in AdaptableOptions.adaptableContext

Action Names

The value for the actionName property can be one of:

  • CALCULATED_COLUMN_ADD
  • CALCULATED_COLUMN_EDIT
  • CALCULATED_COLUMN_DELETE

Event Subscription

Subscribing to the Event is done the same way as with all Adaptable Events:

api.eventApi.on('CalculatedColumnChanged', (eventInfo: CalculatedColumnChangedInfo) => {
    // do something with the info
});

Calculated Column API

MethodDescription
addCalculatedColumn(calcColumn)Adds new Calculated Column
deleteCalculatedColumn(columnId)Deletes Calculated Column with given ColumnId from Adaptable State
editCalculatedColumn(calcColumn)Updates given Calculated Column in Adaptable State
getAggregatedCalculatedColumns()Retrieves all Aggregated Calculated Columns in Adaptable State
getCalculatedColumnById(id)Retrieves Calculated Column by the technical ID (from CalculatedColumnState)
getCalculatedColumnForColumnId(columnId)Gets Calculated Column, if any, for given ColumnId
getCalculatedColumns()Retrieves all Calculated Columns in Adaptable State
getCalculatedColumnState()Retrieves Calculated Column section from Adaptable State
openCalculatedColumnSettingsPanel()Opens Settings Panel with Calculated Column section selected and visible
refreshAggregatedCalculatedColumn(columnId)Re-calculates the aggregated CalculatedColumn (defined with a AggregatedScalarExpression) with the given columnId
refreshAggregatedCalculatedColumns()Re-calculates all aggregated CalculatedColumns (defined with a AggregatedScalarExpression)