Adaptable State Technical Reference

Summary

  • State API is designed to help support to manage AdapTable State at run-time

State Options

PropertyTypeDescriptionDefault
applyStateAdaptableApplyStateFunctionTransforms state before applying it to the application. Called after loadState() but before the state is used.
autoMigrateStatebooleanAutomatically migrate State from previous AdapTable version to current onetrue
clearStateAdaptableClearStateFunctionAllows clearing of remote Adaptable State. Only invoked during StateApi.reloadInitialState() operations.undefined
debounceStateDelaynumberDelay (in ms) to debounce saveState / persistState calls enabling grouping multiple sequential calls in single one (e.g. elevator doors)400
loadStateAdaptableLoadStateFunctionRetrieves saved Adaptable State from storage or external source
persistStateAdaptablePersistStateFunctionHandles the actual storage of state to localStorage, server, etc. Called after saveState() to store the prepared state.
saveStateAdaptableSaveStateFunctionTransforms state before saving to storage. Called before persistState().

State API

The Adaptable API provides an easy way to access all Adaptable State at runtime.

Nearly every class includes functions to allow developers to retrieve particular, relevant, portions of the State.

But the State API class is particularly useful, containing many functions to manage access to AdapTable State:

MethodReturnsDescription
copyAllStateToClipboard()voidCopies all Adaptable state to clipboard
copyUserStateToClipboard()voidCopies User State sections of Adaptable State to clipboard
dispatchStateReadyAction(module)voidSent by each Module when it is Ready
getAdaptableFilterState()AdaptableFilterStateGets filter-related sections of Adaptable State
getAdaptableSortState()AdaptableSortStateGets sort-related sections of Adaptable State
getAlertState(returnJson)AlertStateReturns Alert section of Adaptable State
getAllState()AdaptableStateRetrieves ALL state which is currently stored by Adaptable (both persistent and transient/internal)
getApplicationState(returnJson)ApplicationStateReturns Application section of Adaptable State
getCalculatedColumnState(returnJson)CalculatedColumnStateReturns Calculated Column section of Adaptable State
getChartingState(returnJson)ChartingStateReturns Charting section of Adaptable State
getCustomSortState(returnJson)CustomSortStateReturns Custom Sort section of Adaptable State
getDashboardState(returnJson)DashboardStateReturns Dashboard section of Adaptable State
getDescriptionForModule(adaptableModule)stringRetrieves a brief description of an AdapTable Module
getExportState(returnJson)ExportStateReturns Export section of Adaptable State
getFlashingCellState(returnJson)FlashingCellStateReturns Flashing Cell section of Adaptable State
getFormatColumnState(returnJson)FormatColumnStateReturns Format Column section of Adaptable State
getFreeTextColumnState(returnJson)FreeTextColumnStateReturns FreeText Column section of Adaptable State
getHelpPageForModule(adaptableModule)stringRetrieves the help page for an AdapTable Module
getInitialState()InitialState | anyReturns the Initial Adaptable State
getLayoutState(returnJson)LayoutStateReturns Layout section of Adaptable State
getNamedQueryState(returnJson)NamedQueryStateReturns Query section of Adaptable State
getNoteState(returnJson)NoteStateReturns Note section of Adaptable State
getPersistentState()AdaptablePersistentStateRetrieves the persistent state in Adaptable, i.e. state that is passed to the StateOptions.persistState() function.
getPlusMinusState(returnJson)PlusMinusStateReturns Plus Minus section of Adaptable State
getQuickSearchState(returnJson)QuickSearchStateReturns Quick Search section of Adaptable State
getShortcutState(returnJson)ShortcutStateReturns Shortcut section of Adaptable State
getStatusBarState(returnJson)StatusBarStateReturns StatusBar section of Adaptable State
getStyledColumnState(returnJson)StyledColumnStateReturns StyledColumn section of Adaptable State
getThemeState(returnJson)ThemeStateReturns Theme section of Adaptable State
getToolPanelState(returnJson)ToolPanelStateReturns Tool Panel section of Adaptable State
getUserStateByStateKey(stateKey, returnJson)BaseState | stringReturns given section of Adaptable State (as JSON or object)
incrementUserStateRevision(stateKey)voidAdds '1' to current revision number of State element
loadUserState(state)voidLoads supplied user state, replacing (NOT merging) existing User(persisted) State.
persistAdaptableState()Promise<AdaptableState>Persists the current Adaptable State to storage.
reloadInitialState(newInitialState)Promise<void>Reloads existing (or supplied) Initial State; clears persistent state by calling StateOptions.clearState
setAdaptableStateKey(adaptableStateKey, config)Promise<void>Changes key used for persisting AdaptableState into localStorage; optionally provides an initialState to load

Initial State

Inital State is the Adaptable State provided at design time for first-time use.

The full definition of the object is:

PropertyTypeDescription
AlertAlertStateCollection of AlertDefinitions which will fire Alerts when the rule is met
ApplicationApplicationStateEmpty state section (only populated at Design Time) available for User to store their own data with the rest of AdapTable state.
CalculatedColumnCalculatedColumnStateCollection of CalculatedColumn objects that will display a value based on other cells in the row (using a Calculated Column Expression)
ChartingChartingStateNamed Charts (wrapping Chart models)
CustomSortCustomSortStateCollection of Custom Sort objects to allow some columns to be sorted in non-standard (e.g. non alphabetical) ways
DashboardDashboardStateLarge series of properties to give users full control over the look and feel of the Dashboard - the section above the grid with toolbars and buttons
ExportExportStateCollection of Report objects, together with name of the Current Report, as part of AdapTable export Module
FlashingCellFlashingCellStateDefinitions of which cells flash in response to data changes
FormatColumnFormatColumnStateCollection of FormatColumn objects that will style an entire column either fully or using a Condition
FreeTextColumnFreeTextColumnStateCollection of FreeText objects so users can make their own notes in bespoke columns that will get stored with their state (and not with the DataSource). Useful if needing a 'Comments' column.
LayoutLayoutStateCollection of Layouts to name (and manage) sets of column visibility, order, grouping, sorts, aggregations, filters etc.
NamedQueryNamedQueryStateNamed Queries available for use across multiple AdapTable Modules
NoteNoteStateCollection of personal Notes that are edited at Cell level
PlusMinusPlusMinusStatePlus Minus module: nudge rules. Optional IncrementKey / DecrementKey on each nudge use KeyboardEvent.key; when omitted, AdaptableOptions.plusMinusOptions applies, then + / -.
QuickSearchQuickSearchStateConfigues how Quick Search will run i.e. how and whether to highlight matching cells and to filter out non-matching rows
ShortcutShortcutStateCollection of Shortcut objects to aid data entry and prevent 'fat finger' issues
StatusBarStatusBarStateConfigures the Adaptable Status Bar
StyledColumnStyledColumnStateCollection of Special Column Styles
ThemeThemeStateSpecifies current Theme and lists User and System themes available for selection
ToolPanelToolPanelStateSets order & visibility of Tool Panel controls in AdapTable ToolPanel (on right of grid)
UserInterfaceUserInterfaceStateControls the visibility of AdapTable UI elements (Dashboard, Tool Panel, Status Bar, Menus etc.)

Every item in the object, inherits from BaseState which contains just one property:

PropertyTypeDescription
Revisionnumber | \{ Key: number; UpdateStrategy: 'Override' | 'KeepUserDefined'; \}Version number of the Item - allows developers to update one section in Initial Adaptable State while keeping others unchanged

AdapTable State Events

AdapTable provides 3 State-related Events:

  • BeforeAdaptableStateChanges - fired before something changes in AdapTable State
  • AdaptableStateChanged - fired after anything changes in AdapTable State
  • AdaptableStateReloaded - fired whenever the State reloads

Find Out More

See Listening to Adaptable State for full details

Adaptable State Changed

The full definition of the AdaptableStateChangedInfo object is:

PropertyTypeDescription
actionRedux.ActionThe Redux Action that was invoked
actionNamestringName of the Action
newStateAdaptableStateAdaptable State after the Action
oldStateAdaptableStateAdaptable State before the Action
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext

Before Adaptable State Changes

The full definition of the BeforeAdaptableStateChangeInfo object is:

PropertyTypeDescription
actionRedux.ActionThe Redux Action that is about to be invoked
actionNamestringName of the Action about to be performed
stateAdaptableStateCurrent Adaptable State (before the Action is applied)
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext

Adaptable State Reloaded

The full definition of the AdaptableStateReloadedInfo object is:

PropertyTypeDescription
newStateAdaptablePersistentStateAdaptable State after the reload
oldStateAdaptablePersistentStateAdaptable State before the reload
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext

Base Event Info

Both EventInfo objects from BaseContext defined as follow:

PropertyTypeDescription
adaptableApiAdaptableApiAdaptable Api object
adaptableContextanyCustom application Context provided in AdaptableOptions.adaptableContext
adaptableIdstringId of current AdapTable instance
adaptableStateKeystringCurrent Adaptable State Key
clientTimestampDateTime on user's computer
userNamestringName of Current User

Event Subscription

Subscribing to the Events is done the same as with all Adaptable Events:

api.eventApi.on(
  'AdaptableStateChanged',
  (eventInfo: AdaptableStateChangedInfo) => {
    // do something with the info
  }
);
api.eventApi.on(
  'AdaptableStateReloaded',
  (eventInfo: AdaptableStateReloadedInfo) => {
    // do something with the info
  }
);