Column Scope

Summary

  • Column Scope defines in which columns a given AdapTable feature is applied
  • It can be comprise named Columns, Data Types, Column Types or a whole Row

Column Scope specifies where an AdapTable Feature can be applied.

It sets which columns any given Adaptable Object will be evaluated for.

The Column Scope object has 4 main types of values:

Note

Typically, Scope will include only of these 4 types

  • All - This will include every Column in a Row
  • Column(s) - An array of ColumnIds
  • Data Type(s) - An array of Data Types (available values are: text, number, boolean and date)
  • Column Type(s) - An array of strings which specify which Column Types to use

Where Column Scope is Used

Column Scope is used widely in AdapTable in both Initial Adaptable State sections and Adaptable Options.

Some of the usage for Column Scope includes:

This allows you greater flexibility when creating objects. For instance you can set:

  • one Format Column for all Numeric columns (e.g. Green Font for Positive values)
  • a Data Validation Alert for a given set of named columns
  • a Display Format for all Columns of a bespoke Column Type (e.g. 'pricing')
  • a subset of columns to be exported in a Report

Using Column Scope

The Adaptable UI makes it easy to set the Column Scope of an object that is being created or edited.

UI Step by Step Guide

Setting Column Scope in a Settings Panel Wizard

Configuring Column Scope

It is very straightforward to set Column Scope in Initial Adaptable State:

Scope: All

To set a Scope of All (i.e. the whole row) you need to set 'All' to true:

Scope: { All: true }

Hint

  • This is typically done when the object uses an Expression rather than a Predicate
  • Esentially it will operate over the whole row rather than individual columns

Scope: ColumnIds

To set a Scope on one or more Columns, simply provide an array of ColumnIdsvalues:

Scope: { ColumnIds: ['ItemCost', 'Package Cost', 'OrderCost'] }

Scope: Data Types

To set a Scope of one or more Data Types (e.g. number, text), provide an array of DataTypes values:

Scope: { DataTypes: ['number'] }

Scope: Column Types

To set a Scope of one or more Column Types, provide an array of strings that contain available ColumnTypes:

Scope: { ColumnTypes: ['number-column', 'price', 'calculatedColumn'] }

Scope: Multiple Sections

It is possible - albeit rare - to provide multiple Scope types (e.g. DataType and ColumnIds).

For instance to use Column Formatting to format all date Columns plus 3 other Columns you could do:

Scope: {
    DataTypes: ['date'],
    ColumnIds: ['country', 'currency', 'counterparty']
},

Scope API

The Scope API section of Adaptable API contains a number of methods for managing Column Scope:

MethodReturnsDescription
areAllBooleanColumnsInScope(scope)booleanTrue if all selected columns are boolean
createCellColorRangesForScope(scope)CellColorRange[]Creates a default single CellColorRange for Styled Column wizards (Gradient, Percent Bar, Bullet Chart): Col-MinCol-Max with neutral gray, matching the colour used when adding a range in the Ranges UI. If the column has no sample values yet, returns one 00 gray range.
getAnyColumnIdForScope(scope)string | undefinedGets any ColumnId from the Scope
getColumnIdsInScope(scope)string[] | undefinedReturns all the ColumnIds in the Scope
getColumnsInScope(scope)AdaptableColumn[]Returns list of all Columns in the given Scope
getColumnTypesInScope(scope)string[] | undefinedReturns all the ColumnTypes in the Scope
getDataTypesInScope(scope)ScopeDataType[] | undefinedReturns all the DataTypes in the Scope
getScopeDescription(scope)stringProvides a description for the Scope
getScopeToString(scope)stringGets string representation of the Scope
getSingleColumnInScope(scope)string | undefinedGets the only Column in given Scope
isColumnInDateScope(column, scope)booleanTrue if Scope has Data DataType which contains Column
isColumnInNumericScope(column, scope)booleanTrue if Scope has Numeric DataType containing Column
isColumnInScope(column, scope)booleanTrue if Column is in given Scope
isColumnInScopeColumns(column, scope)booleanTrue if Column is in Scope's 'ColumnIds' section
isColumnInTextScope(column, scope)booleanTrue if Scope has text DataType containing Column
isPrimaryKeyColumnInScopeColumns(scope)booleanWhether PK column is included in Scope's column section
isScopeInScope(scopeA, scopeB)booleanTrue if first scope is in second Scope
isSingleBooleanColumnScope(scope)booleanTrue if Scope contains just 1 boolean Column
isSingleColumnScope(scope)booleanTrue if Scope contains just 1 ColumnId
isSingleNumericColumnScope(scope)booleanTrue if Scope contains just 1 numeric Column
scopeHasColumns(scope)booleanTrue if Scope contains ColumnIds
scopeHasColumnType(scope)booleanTrue if Scope contains ColumnTypes
scopeHasDataType(scope)booleanTrue if Scope contains DataTypes
scopeHasOnlyBooleanDataType(scope)booleanTrue if Scope is DataTypes and contains just 'Boolean'
scopeIsAll(scope)booleanTrue if Scope is 'All'
scopeIsEmpty(scope)booleanTrue if Scope is empty