Adaptable Column

Summary

  • AdapTable creates an AdaptableColumn object for every AG Grid Column each time the Application starts
  • AdapTable Columns are created from 3 sources:
    • Every column defined in columnDefs property 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.)
  • Many objects in Initial Adaptable State rely heavily on Columns and generally use the columnId property

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:

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:

PropertyDescription
columnIdName of Column in AG Grid (e.g. field or colId)
columnTypesColumn Types of the Column
dataTypeDataType of the Column
friendlyNameHow Column is referred to in Adaptable UI; Caption property in AG Grid
IsReadOnlySets 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 ColDef definition using the cellDataType property
  • 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:

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 readOnly set to true)

Column Properties

The full list of properties in the AdaptableColumn object is:

PropertyDescription
aggregatableIs Column able to display aggregations (e.g. 'sum') when grouped
aggregationFunctionCustom Aggregation function for the Column
availableAggregationFunctionsAvailable Aggregations for the Column
columnGroupThe parent Column group (if Column belongs to one)
exportableWhether the Column can be included in Reports
fieldField in the row to get cell data from
fieldOnlyIs the Column ONLY available as a field and never visible
filterableIs Column able to be filtered
flexFlex details of the Column
groupableCan Column form a Row Group
hideableCan Column be removed from the grid
isActionColumnIs Column an Action Column
isCalculatedColumnIs Column a Calculated Column
isFixedIs Column pinned or locked into position
isFreeTextColumnIs Column a Free Text Column
isGeneratedPivotResultColumnIs Column a generated Pivot Result Column
isGeneratedRowGroupColumnIs Column a generated Row Group Column
isGeneratedSelectionColumnIs Column a generated Selection Column
isGroupedIs Column currently Row-Grouped
isPivotTotalColumnIs Column a Pivot Total Column (GrandTotal, GroupTotal, AggregationTotal)
isPrimaryKeyIs this the Primary Key Column
isSparklineIs it a Sparkline Column
isTreeColumnWhether Column is the Tree Column (in Tree View)
isUIHiddenColumnWhether Column is always hidden in UI but still available programmatically
moveableCan Column be moved at run-time to a new position
pinnedThe pinned position of the Column
pivotableCan Column be used in a Pivot Layout
queryableCan the Column be in included in Queries / Expressions
readOnlyIs Column editable; returns FALSE if Column has conditional/dynamic editability, assuming some rows are editable
resizableIs Column resizable
sortableIs Column sortable
visibleIs Column currently visible
widthColumn width
IsReadOnlySets 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: true
Boolean
Show a Warning when Columns are Missing

Find Out More

See Column Types: Scope for how to provide column types that are available when scoping objects

Column Options Properties

PropertyDescriptionDefault
addColumnGroupToColumnFriendlyNameAppends the name of the Column Group to a Column's Friendly Namefalse
columnFriendlyNameProvide an alternative Friendly Name for a Columnundefined
columnHeaderProvide a custom Header Name for a Table or Pivot Column
columnTypesOptional list of Column Types - used for Scope and creating Special ColumnsEmpty Array
showMissingColumnsWarningLog warning to console if AdapTable cannot find a columntrue

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:

MethodDescription
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