Scope

Version 7 of AdapTable introduced a new concept called Scope.

Specifies where an object or function can be applied. It has 3 main values:

  • All - This will include every Column in a Row
  • Column(s) - An Array of ColumnIds
  • DataType(s) - An Array of Data Types (available values are: 'Boolean', 'Number', 'Date', 'String')

Functions Using Scope

The Scope object has been included in a number of functions including:

This means that it is now possible to create a Conditional Style for all Numeric columns (e.g. Green Font for Positive values) with a single step.

Setting Scope

It is very straightforward to set Scope in Predefined Config:

Scope: All

To set a Scope of All you need to set 'All' to true as follows:

Scope: {
All: true,
},
tip

This is typically done when using an Expression rather than a Predicate and essentially will work on the whole row rather than individual columns.

Scope: ColumnIds

To set a Scope on one or more ColumnIds, simply provide an array of values:

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

Scope: Data Types

To set a Scope of one or more Data Types, provide an array of values:

Scope: {
DataTypes: ['Number'],
},

Scope: Multiple Types

It is possible - albeit rare - to include both DataType and ColumnIds in Scope.

For instance if you wanted a Conditional Style to paint all Date Columns plus 3 string 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 Scope.

MethodDescription
getColumnIdsInScope(scope)Returns all the ColumnIds in the Scope
getColumnsForScope(scope)Returns a list of all Columns in the given Scope
getDataTypesInScope(scope)Returns all the DataTypes in the Scope
getScopeDescription(scope)Provides a description for the Scope
getScopeToString(scope)Gets a string representation of the Scope
isColumnInDateScope(column, scope)Returns true if Scope has Data DataType which contains Column
isColumnInNumericScope(column, scope)Returns true if Scope has Numeric DataType containing Column
isColumnInScope(column, scope)Returns true if Column is in given Scope
isColumnInScopeColumns(column, scope)Returns true if Column is in Scope's 'ColumnIds' section
isColumnInStringsScope(column, scope)Returns true if Scope has String DataType containing Column
isPrimaryKeyColumnInScopeColumns(scope)Whether PK column is included in Scope's column section
isScopeInScope(scopeA, scopeB)Returns true if first scope is in second Scope
isSingleColumnScope(scope)Returns true if Scope contains just 1 ColumnId
scopeHasColumns(scope)Returns true if Scope contains ColumnIds
scopeHasDataType(scope)Returns true if Scope contains DataTypes
scopeIsAll(scope)Returns true if Scope is 'All'
scopeIsEmpty(scope)Returns true if Scope is empty