Adaptable Column
Summary
- AdapTable creates an
AdaptableColumnobject for every AG Grid Column each time the Application starts - AdapTable Columns are created from 3 sources:
- Every column defined in
columnDefsproperty of AG Grid GridOptions - Special Columns used in AdapTable - i.e. Action, Calculated and FreeText Columns
- Columns dynamically created by AG Grid (e.g. Row Grouped Columns, Pivot Columns, Tree Columns etc.)
- Every column defined in
- Many objects in Initial Adaptable State rely heavily on Columns and generally use the
columnIdproperty
When AdapTable is being initialised it dynamically creates a collection of AdaptableColumn objects.
There is one Adaptable Column for every column in the Grid, and they can be of 3 types:
-
Based on the
ColDefprovided in thecolumnDefsproperty of GridOptions -
Created for each Special Column provided to AdapTable (of which there are 3 types):
-
Matching columns that are dynamically created by AG Grid - these include:
Hint
See below how AdapTable sets the properties of the AdapTable Column
AdapTable Column Base
The AdaptableColumn object is derived from AdaptableColumnBase which contains these properties:
| Property | Description |
|---|---|
| columnId | Name of Column in AG Grid (e.g. field or colId) |
| columnTypes | Column Types of the Column |
| dataType | DataType of the Column |
| friendlyName | How Column is referred to in Adaptable UI; Caption property in AG Grid |
| IsReadOnly | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full') |
These contain the most important properties of the Column object and are worth looking at in more detail:
columnId
This is the primary way of referring to the Column, and what is generally used in Initial Adaptable State.
friendlyName
This property sets how the Column is referred to throughout the AdapTable UI.
This includes the Expression Editor and all panels in the Settings Panel.
It is usually derived automatically from the headerName property in the AG Grid Column definition, but it can be provided explicitly in the columnFriendlyName function property in Column Options.
Hint
This is useful where you might have multiple columns with the same header (e.g. 'Price' or 'Bid') and you want to be able to differentiate between them in the UI
dataType
This important property determines whether the Column is a number, string, date, boolean etc.
This influences many things in AdapTable e.g. what Column Filters are available.
AdapTable derives the value of the DataType, in the first instance by using the Cell Data Type of the AG Grid Column Definition if provided.
Note
- The Cell Data Type is assigned to the Column's AG Grid
ColDefdefinition using thecellDataTypeproperty - It is strongly advised that all AG Grid Col Definitions should include this property
columnTypes
This is based off the types property of the AG Grid Column Definition.
AdapTable will add additional values to this prop in some use cases (as detailed in this tutorial).
Deep Dive
How are these Properties set?
AdapTable Column Object
The Adaptable Column object extends AdaptableColumnBase and includes a large number of properties.
These properties are evaluated by AdapTable when the Application starts.
The evaluation varies based on the source of the Column.
Regular Columns
Regular columns are those which are defined initially in AG Grid GridOptions object.
AdapTable will work out the values for that Column's properties in AdapTable Column in 2 ways:
-
using the values provided in the AG Grid Column Definition
Note
Examples are
field,groupable,movable,sortable- all based off similar properties in Grid Options -
reading some properties provided in Adaptable Options, for example:
exportable- derived from theisColumnExportableproperty in Export Optionsqueryable- derived fromisColumnQueryableproperty Expression Options
Special Columns
AdapTable can create 'Special Columns' which are not defined in Grid Options but through AdapTable itself.
Examples include Calculated Columns, FreeText Columns and Action Columns.
In these cases AdapTable uses a combination of:
- properties provided in the object definitions in Initial Adaptable State
- sensible defaults for the Column (e.g. Action Columns have
readOnlyset to true)
Column Properties
The full list of properties in the AdaptableColumn object is:
| Property | Description |
|---|---|
| aggregatable | Is Column able to display aggregations (e.g. 'sum') when grouped |
| aggregationFunction | Custom Aggregation function for the Column |
| availableAggregationFunctions | Available Aggregations for the Column |
| columnGroup | The parent Column group (if Column belongs to one) |
| exportable | Whether the Column can be included in Reports |
| field | Field in the row to get cell data from |
| fieldOnly | Is the Column ONLY available as a field and never visible |
| filterable | Is Column able to be filtered |
| flex | Flex details of the Column |
| groupable | Can Column form a Row Group |
| hideable | Can Column be removed from the grid |
| isActionColumn | Is Column an Action Column |
| isCalculatedColumn | Is Column a Calculated Column |
| isFixed | Is Column pinned or locked into position |
| isFreeTextColumn | Is Column a Free Text Column |
| isGeneratedPivotResultColumn | Is Column a generated Pivot Result Column |
| isGeneratedRowGroupColumn | Is Column a generated Row Group Column |
| isGeneratedSelectionColumn | Is Column a generated Selection Column |
| isGrouped | Is Column currently Row-Grouped |
| isPivotTotalColumn | Is Column a Pivot Total Column (GrandTotal, GroupTotal, AggregationTotal) |
| isPrimaryKey | Is this the Primary Key Column |
| isSparkline | Is it a Sparkline Column |
| isTreeColumn | Whether Column is the Tree Column (in Tree View) |
| isUIHiddenColumn | Whether Column is always hidden in UI but still available programmatically |
| moveable | Can Column be moved at run-time to a new position |
| pinned | The pinned position of the Column |
| pivotable | Can Column be used in a Pivot Layout |
| queryable | Can the Column be in included in Queries / Expressions |
| readOnly | Is Column editable; returns FALSE if Column has conditional/dynamic editability, assuming some rows are editable |
| resizable | Is Column resizable |
| sortable | Is Column sortable |
| visible | Is Column currently visible |
| width | Column width |
| IsReadOnly | Sets Entity to ReadOnly (overwriting a Strategy Entitlement of 'Full') |
Using AdapTable Columns
Run-time users leverage AdapTable Columns continuously but indirectly through AG Grid. The overwhelming majority of users of AdapTable will not need to be aware of the existence of AdapTable Columns.
Developers will frequently access AdapTable Columns since they are often contained in Context objects supplied to functions, and used elsewhere in AdapTable (e.g. in the Column Menu).
Caution
Developers will never create AdapTable Columns as they are provided dynamically by AdapTable
Column Options
The ColumnOptions section of Adaptable Options contains properties for managing Adaptable Columns.
showMissingColumnsWarning
Default: trueBooleanFind Out More
See Column Types: Scope for how to provide column types that are available when scoping objects
Column Options Properties
| Property | Description | Default |
|---|---|---|
| addColumnGroupToColumnFriendlyName | Appends the name of the Column Group to a Column's Friendly Name | false |
| columnFriendlyName | Provide an alternative Friendly Name for a Column | undefined |
| columnHeader | Provide a custom Header Name for a Table or Pivot Column | |
| columnTypes | Optional list of Column Types - used for Scope and creating Special Columns | Empty Array |
| showMissingColumnsWarning | Log warning to console if AdapTable cannot find a column | true |
Column API
AdapTable provides the Column API class in Adaptable API to enable programmatic access to all the AdapTable Columns which have been created.
This includes a plethora of methods giving full access to the full range of properties in each Column:
| Method | Description |
|---|---|
| addColumnsToSelection(columnIds) | Adds (highlights) a group of Columns to any existing selection |
| addColumnToSelection(columnId) | Adds (highlights) a Column to any existing selection |
| autosizeAllColumns() | Autosizes all Columns in the Grid |
| autosizeColumn(columnId) | AutoSizes a Column |
| autosizeColumns(columnIds) | Autosizes given Columns |
| doesColumnExist(columnId) | Checks if Column has already been created |
| getAggregatableColumns() | Returns all Aggregatable Columns |
| getAGGridColDefForColumnId(columnId) | Returns AG Grid ColDef for a given ColumnId |
| getAGGridColumnForColumnId(columnId) | Returns the AG Grid Column for a given ColumnId |
| getArrayColumns() | Returns all array columns (number, tuple-number, object-number & text) |
| getBooleanColumns() | Returns all boolean Columns |
| getColumnDataTypeForColumnId(columnId) | Returns Data Type for the Column with given ColumnId |
| getColumnIdForFriendlyName(friendlyName) | Retrieves ColumnId for Column with given Friendly Name |
| getColumnIdsForFriendlyNames(friendlyNames) | Retrieves ColumnIds for Columns with given Friendly Names |
| getColumns() | Returns all Columns available (including hidden, special) |
| getColumnsByColumnType(columnType) | Returns all columns of a given columnType |
| getColumnSummaryForColumnId(columnId) | Gets summary info for a column including filters and unique values |
| getColumnsWithColumnIds(columnIds) | Retrieves Adaptable Columns with given ColumnIds |
| getColumnsWithDataType(dataType) | Returns all Columns that have given DataType |
| getColumnsWithFriendlyNames(friendlyNames) | Retrieves Adaptable Columns with given Friendly names |
| getColumnTypes() | Returns available columns types defined under columnOptions.columnTypes |
| getColumnWithColumnId(columnId, logWarning) | Retrieves AdapTable Column with given ColumnId |
| getColumnWithFriendlyName(columnName, logWarning) | Retrieves AdapTable Column with given Friendly name |
| getDateColumns() | Returns all Date Columns |
| getDefaultAggFunc(columnId) | Returns the default Aggregation Function for a Column |
| getExportableColumns() | Returns all Exportable Columns |
| getFilterableColumns() | Returns all Sortable Columns |
| getFriendlyNameForColumnId(columnId, layout) | Retrieves Friendly Name of Column with given ColumnId |
| getFriendlyNamesForColumnIds(columnIds) | Retrieves Friendly Names for given ColumnIds |
| getGroupableColumns() | Returns all Groupable Columns |
| getNonSpecialColumns() | Returns all UI available columns excluding Action, FreeText and Calculated Columns |
| getNumberArrayColumns() | Returns all number-array columns |
| getNumericArrayColumns() | Returns all numeric array columns (number, tuple-number, object-number) |
| getNumericColumns() | Returns all numeric Columns |
| getObjectNumberArrayColumns() | Returns all object-number-array columns e.g. [x:1,y:2,x:3,y:4] |
| getPivotableColumns() | Returns all Pivotable Columns |
| getPrimaryKeyColumn() | Retrieves current Primary Key Column in AdapTable. It may be undefined if the primary key is auto-generated, or it is NOT mapped to a column. |
| getQueryableColumns() | Returns all Queryable Columns |
| getRowGroupedColumns() | Returns all columns currently Row Grouped |
| getSortableColumns() | Returns all Sortable Columns |
| getSpecialColumns() | Returns any Action, FreeText and Calculated Columns |
| getTextArrayColumns() | Returns all string array Columns |
| getTextColumns() | Returns all Text Columns |
| getTupleNumberArrayColumns() | Returns all tuple-number-array columns e.g. [[1,2],[3,4]] |
| getUIAvailableColumns() | Returns all Columns that can be displayed in UI (excludes always hidden cols) |
| getUIHiddenColumns() | Returns Columns that are always hidden in UI (but available for Expressions) |
| getVisibleColumns() | Returns all visible Columns |
| hasArrayDataType(columnId) | Checks if the Column with the given columnId has any Array-like DataType (TextArray,NumberArray,TupleNumberArray or ObjectNumberArray) |
| hasBooleanDataType(columnId) | Checks if the Column with the given columnId has DataType Boolean |
| hasColumnType(columnIdentifier, columnType) | Checks if the Column with given Column Identifier (columnId or ColDef) has a specific Column Type |
| hasDateDataType(columnId) | Checks if the Column with the given columnId has DataType Date |
| hasNumberDataType(columnId) | Checks if the Column with the given columnId has DataType Number |
| hasNumericArrayDataType(columnId) | Checks if the Column with the given columnId has an Numeric Array-like DataType (NumberArray,TupleNumberArray or ObjectNumberArray) |
| hasTextArrayDataType(columnId) | Checks if the Column with the given columnId has a Text Array-like DataType (TextArray) |
| hideColumn(columnId) | Hides a Column from Grid |
| isActionColumn(columnId) | Checks if Column with given ColumnId is an Action Column |
| isAgGridGeneratedColumn(columnId) | Whether column is auto generated by AG Grid (for selection, grouping, pivoting etc) |
| isAutoRowGroupColumn(columnId) | Checks if Column with given ColumnId is a row-group Column automatically generated by AG Grid |
| isAutoRowGroupColumnForMulti(columnId) | Checks if Column with given ColumnId is a row-group Column automatically generated by AG Grid, for row-grouping with group display type = 'multi' |
| isAutoRowGroupColumnForSingle(columnId) | Checks if Column with given ColumnId is a row-group Column automatically generated by AG Grid, for row-grouping with group display type = 'single' |
| isCalculatedColumn(columnId) | Checks if Column with given ColumnId is a Calculated Column |
| isColumnInGrid(columnId) | Returns true if the given Column exists in the Grid |
| isFdc3Column(columnId) | Checks if Column with given ColumnId is a FDC3 Column |
| isFreeTextColumn(columnId) | Checks if Column with given ColumnId is a Free Text Column |
| isPivotAggColumnWithNoPivotColumns(columnId) | Checks if Column with given ColumnId is a pivot aggregation column in a pivot layout with no pivot columns. When PivotColumns is empty, aggregation columns keep their original IDs instead of getting a 'pivot_' prefix. |
| isPivotResultColumn(columnId) | Checks if Column with given ColumnId is a pivot Column automatically generated by AG Grid |
| isSelectionColumn(columnId) | Checks if Column with given ColumnId is a Selection (Checkbox) Column automatically generated by AG Grid |
| isSpecialColumn(columnId) | Checks if Column with given ColumnId is a Special (i.e. calculated, freetext or action) Column |
| openColumnInfoSettingsPanel() | Opens Settings Panel with Column Info section selected and visible |
| selectAllColumns() | Selects all Columns |
| selectColumn(columnId) | Selects (highlights) a Column |
| selectColumns(columnIds) | Selects (highlights) group of Columns |
| setColumnCaption(columnId, caption) | Sets a new Caption / Header for a Column (only for current Layout) |
| showColumn(columnId) | Makes a Column visible |