Adaptable

#Flashing Cells

Flashing cells briefly style a cell — or its whole row — when its value changes, so users notice updates in fast-moving data. The style depends on the direction of the change: up, down, or neither.

Flashing cells are defined globally in the Adaptable state (under flashingCell), but they only apply to the views that list them in their flashingCells property:

A flashing cell, active in one view
const state: AdaptableUserState = {
  flashingCell: {
    flashingCells: {
      'price-and-volume': {
        label: 'Price and volume',
        scope: { columns: ['price', 'volume'] },
        flashDuration: 500,
      },
    },
  },
  view: {
    currentViewId: 'default',
    views: [
      {
        id: 'default',
        label: 'Live prices',
        flashingCells: ['price-and-volume'],
      },
    ],
  },
};
#
Flashing on live updates

Two random stocks get a new price every 400ms (and sometimes a new volume). Rising numbers flash green, falling ones red, for half a second.

open
loading demo…

#What makes a cell flash

Flashing reacts to updates in the data source: edits made in the grid and updates made through the API. For streaming data, send each update with adaptableApi.dataSourceApi.updateData (or updateDataArray for a batch) — an object with the primary key and the fields that changed:

adaptableApi.dataSourceApi.updateData({ symbol: 'AAPL', price: 191.2 });

Every changed field is checked against the current view's flashing cells: when its column is in a flashing cell's scope and the row satisfies the flashing cell's condition (if it has one), the cell flashes. Inserted and deleted rows don't flash.

When several flashing cells of a view match the same change, the first one in the view's flashingCells list wins.

#Configuring a flashing cell

PropertyDescription
conditionan AdaptableQL expression the changed row must satisfy, e.g. [sector] = "Technology"
downChangeStylestyle when a number goes down
flashDurationhow long the flash lasts, in milliseconds
flashTarget'Cell' (default) flashes the changed cell, 'Row' the whole row
labelthe name shown in the settings panel
neutralChangeStylestyle for any other change — text, dates, or a number set to the same value
scopethe columns that flash: columns, columnTypes or dataTypes. No scope means every column
upChangeStylestyle when a number goes up

Up and down apply to number columns only. The default styles use the theme's success (up), error (down) and info (neutral) colors as the background.

Note

Without a flashDuration, a flash doesn't fade: the cell keeps the style until the user picks Remove Flashing from the cell's context menu.

#
Custom styles, a condition and whole rows

Only rows where [sector] = "Technology" flash, the whole row flashes, and the up and down styles are custom. The price column is editable too — double-click a price and change it.

open
loading demo…

#Flashing cells in the UI

The column menu of a column that doesn't flash yet offers Add Flashing Cell, which creates a flashing cell for that column (with a 300ms duration and the default styles) and activates it in the current view. Remove Flashing Cell appears when the column has a flashing cell that targets only that column.

The settings panel has a Flashing Cells page where users create, edit and delete flashing cells, with a preview of the up, down and neutral styles. The page lists the flashing cells active in the current view — drag them to change their priority — with the other definitions below, ready to be added to the view. The flashingCell dashboard widget opens that page.

The page is also available standalone as <adaptable-flashing-cells-manager> (needs only an <adaptable-provider> ancestor):

<adaptable-provider
  adaptableId="my-grid"
  primaryKey="symbol"
  [data]="data"
  [defaultState]="defaultState"
>
  <adaptable-ui />
  <adaptable-flashing-cells-manager />
</adaptable-provider>

For fully custom UIs, the injectFlashingCells() function (the Angular counterpart of the useFlashingCells hook) exposes the same operations. Call it in a component rendered inside <adaptable-provider>; it returns a signal of an object with them:

import { injectFlashingCells } from '@adaptabletools/datagrid-angular';

// a component rendered inside <adaptable-provider>
@Component({ selector: 'my-flashing-toolbar', template: `<!-- ... -->` })
class MyFlashingToolbar {
  // a signal: read it where you use it, so it is always current
  private readonly flashingCellsModel = injectFlashingCells();

  onToolbarAction() {
    const {
      flashingCells, // all flashing cells defined in state
      currentViewFlashingCellIds, // active in the current view, in priority order
      isInCurrentView, // (id) => boolean
      createFlashingCell, // (config, { addToCurrentView? }) => id
      updateFlashingCell, // (id, config) => void
      deleteFlashingCell, // (id) => void — also removed from every view
      addToCurrentView,
      removeFromCurrentView,
      setCurrentViewFlashingCells, // (orderedIds) => void — sets the priority order
    } = this.flashingCellsModel();

    // ...
  }
}

Imperatively, adaptableApi.flashingCellsApi offers createFlashingCell, updateFlashingCell, deleteFlashingCell, getFlashingCells and getCurrentViewFlashingCells.

Tip

To react to a change with a message rather than a style, use alerts. When an alert highlight and a flash hit the same cell, the alert highlight is shown.