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:
| Property | Description |
|---|---|
| CalculatedColumns | Collection of Calculated Columns |
Calculated Column
The Calculated Column is defined as follows:
| Property | Description |
|---|---|
| CalculatedColumnSettings | Additional optional properties for Column (e.g. filterable, resizable) |
| ColumnId | Name of Calculated Column |
| FriendlyName | Name to be used in Column Header; if blank ColumnId is used |
| Query | Scalar/AggregatedScalar Query used by AdapTableQL to evaluate Column's value |
| IsReadOnly | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full') |
Calculated Column Settings
The Calculated Column Settings property contains additional options for the Calculated Column:
| Property | Description | Default |
|---|---|---|
| ShowToolTip | Show underlying Expression as ToolTip when hovering over a cell | false |
But it also inherits from SpecialColumnSettings which is defined as follows:
| Property | Description | Default |
|---|---|---|
| Aggregatable | Whether Column can be used in an aggregation when grouping | false |
| ColumnTypes | Custom column types added to AG Grid Column Types when object is created | |
| DataType | Expression's return value DataType, only mandatory property | |
| Filterable | Whether Column is filterable | false |
| Groupable | Whether Column can be grouped | false |
| HeaderToolTip | Tooltip to show in the Column Header (not cells) | |
| Pivotable | Whether Column can be used when grid is in pivot mode | false |
| Resizable | Whether Column can be resized (by dragging column header edges) | false |
| Sortable | Whether Column is sortable | false |
| SuppressMenu | Whether if no menu should be shown for this Column header. | false |
| SuppressMovable | Whether if this Column should be movable via dragging | false |
| Width | Preferred (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.
| Property | Description |
|---|---|
| actionName | What caused CalculatedColumn State to change (i.e. Add, Edit, Delete) |
| calculatedColumn | Calculated Column that has been added, edited or deleted |
| calculatedColumnExpressionAST | AST for Current Calculated Column Expression |
| adaptableContext | Custom application Context provided in AdaptableOptions.adaptableContext |
Action Names
The value for the actionName property can be one of:
CALCULATED_COLUMN_ADDCALCULATED_COLUMN_EDITCALCULATED_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
| Method | Description |
|---|---|
| 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) |