# Flashing Cells and Rows in AdapTable

Canonical page: https://www.adaptabletools.com/docs/handbook-flashing-cell

- AdapTable can flash Cells (or Rows) when a Rule becomes true
- Most Flashing Cell Definitions are Change based - but Observable rules are also supported
- Flashing Rules can be created in the UI or defined in Initial Adaptable State
- All Flashing-related properties (e.g. flashing styles, duration, target etc.) are highly configurable

Flashing Cells in AdapTable allows users to see changes in cell values that matter to them.

They apply short-lived highlights when data changes or while an [Observable Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression-observable/index.md) is true.

- Flashing Cells complement [Format Columns](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) (cell formats & styles) and [Styled Columns](https://www.adaptabletools.com/docs/handbook-styled-column-overview/index.md) (dedicated renderers)
- Flashing has the **highest** style precedence — see [Style Precedence in AdapTable](https://www.adaptabletools.com/docs/handbook-column-formatting-configuring/index.md#format-column-precedence)

Definitions live in **`FlashingCell` state** (and the Flashing Cell wizard).

Default colours, duration, and target come from **`flashingCellOptions`** — see [Configuring Cell Flashing](https://www.adaptabletools.com/docs/handbook-flashing-cell-configuring/index.md).

## Topics in this Section

| Topic                                                                                      | Summary                                                                            |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| This page                                                                                  | Scope, rule, styles, duration, target, wizard, column menu, FAQ                    |
| [Observable Flashing](https://www.adaptabletools.com/docs/handbook-flashing-cell-observables/index.md)       | History or time rules for when cells should flash                                  |
| [Flashing Rows](https://www.adaptabletools.com/docs/handbook-flashing-row/index.md)                          | `FlashTarget: row`, duration `always`, clearing a row flash                        |
| [Configuring Cell Flashing](https://www.adaptabletools.com/docs/handbook-flashing-cell-configuring/index.md) | **`flashingCellOptions`** defaults and precedence when definitions omit properties |
| [Technical Reference](https://www.adaptabletools.com/docs/technical-reference-flashing-cell/index.md)        | State shapes, API, **`FlashingCellDisplayed`** event                               |

Cells or Rows can be made to flash:

- on any change or when the change meets a defined rule
- or when an [Observable Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression-observable/index.md) over history / time becomes true

## Flashing Concepts

Flashing in AdapTable comprises 5 key concepts:

- [Scope](#scope): **which** Columns or DataTypes when changed will cause the Flash to happen
- [Rule](#rule): **why** the Flash is applied (i.e. what condition - or observable - causes a Cell or Row to flash)
- [Styles](#change-styles): **how** the Flash is applied - different styles are available for up, down and neutral changes
- [Duration](#duration): **when** (i.e. how long) the Flash will be applied - either a number (of milliseconds) or 'always'
- [Target](#target): **where** the Flash is applied - either the cell whose data changed, or the whole row

You can set defaults for all these properties - so they are only overridden when they do not meet requirements

A Flashing Cell Definition can be limited to specific Layouts via [Layout Extensions](https://www.adaptabletools.com/docs/handbook-layouts-extending/index.md)

**Example: Flashing Cells**

Flashing Cells on Any Change

- This very basic example sets all `numeric` columns to flash (and has dummy data 'ticking' regularly)
- The Definition is Type `Change` with `ANY_CHANGE()` so every data change causes a Flash
- The default settings for colours and durations are used

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts      [template]
  columnDefs.ts         [template]
  gridOptions.ts        [template]
  index.ts              [template]
  onAdaptableReady.ts
  rowData.ts            [template]
  styles.css            [template]
  tickingDataHelper.ts  [template]
index.html              [template]
package.json            [template]
tsconfig.json           [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Flashing Basic',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FlashingCell'],
    },
    Theme: {CurrentTheme: 'dark'},
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'flashingCell-numeric-anyChange',
          Type: 'Change',
          Scope: {
            DataTypes: ['number'],
          },
          Rule: 'ANY_CHANGE()',
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'license',
            'github_watchers',
            'language',
            'open_issues_count',
            'closed_issues_count',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'description',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';
import {tickNumericData} from './tickingDataHelper';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  tickNumericData(adaptableApi, 500, [
    'github_stars',
    'github_watchers',
    'open_issues_count',
    'closed_issues_count',
  ]);
};
```

### Scope

Users can specify which columns or rows in AdapTable are able to flash.

This is done by leveraging the commonly-used [Column Scope Object](https://www.adaptabletools.com/docs/dev-guide-columns-scope/index.md).

Scope contains up to 4 sets of options:

- **Selected Columns** - a list of Columns which will Flash

[FreeText](https://www.adaptabletools.com/docs/handbook-freetext-column/index.md) Columns can flash when changed. [Calculated Columns](https://www.adaptabletools.com/docs/handbook-calculated-column/index.md) flash when a referenced column's value changes — see [Flashing Calculated Columns](https://www.adaptabletools.com/docs/handbook-calculated-column-referencing/index.md#flashing-calculated-columns).

- **Data Types** - All columns which have a particular data type (e.g. `number`, `text` or `date`)
- **Column Types** - All columns which contain the selected [Column Type](https://www.adaptabletools.com/docs/dev-guide-columns-column-types/index.md)
- **All Columns** - An entire Row can be Flashed by providing a Scope of 'All'

### Rule

The Rule determines whether a Cell or Row should Flash.

It is an [Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md) evaluated with [AdapTableQL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md).

The rule can include:

- Relative Change Functions (`ANY_CHANGE`, `PERCENT_CHANGE`, `ABSOLUTE_CHANGE`) and / or
- Value comparisons, evaluated per data change (similar to [Alert Rules](https://www.adaptabletools.com/docs/handbook-alerting/index.md) and [Conditional Styles](https://www.adaptabletools.com/docs/handbook-column-formatting-conditions/index.md))

The most common Change Rule is `ANY_CHANGE` which returns true [for any data change](https://www.adaptabletools.com/docs/adaptable-ql-expression-relative-change/index.md#any-change)

When the Flashing Cell Scope covers multiple columns or a Data Type, use [$SCOPE](https://www.adaptabletools.com/docs/adaptable-ql-expression-advanced-scope-function/index.md) to refer to the column that changed - e.g. `ANY_CHANGE($SCOPE) AND $SCOPE > 5000`.

**Example: Flashing Cells using a Rule**

Flashing Cells when change matches a Rule

- In this example cells in 4 columns (`Github Stars`, `Github Watchers`, `Open Issues`, `Closed Issues`) tick regularly
- The Definition is Type `Change`; they **only** flash when the ticking data change occurs in a row where the `Language` is 'JavaScript'.

- Change the Rule so it flashes also (or instead) for TypeScript projects

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts      [template]
  columnDefs.ts         [template]
  gridOptions.ts        [template]
  index.ts              [template]
  onAdaptableReady.ts
  rowData.ts            [template]
  styles.css            [template]
  tickingDataHelper.ts  [template]
index.html              [template]
package.json            [template]
tsconfig.json           [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Cell Flashing Rule',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FlashingCell'],
    },
    Theme: {CurrentTheme: 'dark'},
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'flashingCell-language-JavaScript',
          Type: 'Change',
          Scope: {
            ColumnIds: [
              'github_stars',
              'github_watchers',
              'open_issues_count',
              'closed_issues_count',
            ],
          },
          Rule: '[language] = "JavaScript"',
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'github_stars',
            'license',
            'github_watchers',
            'language',
            'open_issues_count',
            'closed_issues_count',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'description',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';
import {tickNumericData} from './tickingDataHelper';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  tickNumericData(adaptableApi, 300, [
    'github_stars',
    'github_watchers',
    'open_issues_count',
    'closed_issues_count',
  ]);
};
```

### Observable

It is also possible to create an [Observable Flashing Rule](https://www.adaptabletools.com/docs/handbook-flashing-cell-observables/index.md).

When this happens the cell flashes while a [live Observable Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression-observable/index.md) evaluates to true.

The Observable Expression can evaluate either using history or time.

- This allows you to set flashing on a nth change rather than all changes (and in a desired time period)
- e.g. to set Price to flash when it changes 3 times in 5 mins use: `CHANGE_COUNT{[price], WITHIN(5m)} > 3`

### Change Styles

There are 3 "Change Styles" for the Flash (which are all configurable):
| Style | When Invoked | Column Data Types |
| ----------- | ------------------------------- | ----------------- |
| **Up** | Data change direction is `up` | number, date |
| **Down** | Data change direction is `down` | number, date |
| **Neutral** | Data change has no direction | text, boolean |

### Duration

Duration sets for how long the cell / row will flash.
The value provided can be one of 2 types:

- a number (expressed in milliseconds)
- 'always' - which will keep the cell / row in the new style indefinitely
  
  Use the `Clear Flash` [Context Menu Item](https://www.adaptabletools.com/docs/ui-context-menu/index.md) to remove a currently applied Flash Style from cells or rows
  

### Target

Target defines what will Flash. There are 2 options:

- **Cell** - the cell that triggered the data change
- **Row** - the entire row which contains the cell which triggered the data change
  
  See [Flashing Rows](https://www.adaptabletools.com/docs/handbook-flashing-row/index.md) for more on using the `Row` Trigger
  

## Using Flashing Cells

Run-time access to Cell Flashing is primarily available in the Flashing Cell section of the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md).
This displays a list of existing Flashing Cell Definitions with buttons to edit, suspend, share or delete.
### Using the Flashing Cell Wizard

There are a few steps required when creating a Cell Flashing Rule:

Pick **Change** or **Observable**:

- **Change** — flash from the nature of a cell change (any / percent / absolute) or a value comparison
- **Observable** — flash from how a value has changed over time (counts, moves, highs/lows, silence)

Changing Type clears the Rule, because the two Types use different Expression forms.

Provide a unique name for the Flashing Cell Definition.
Set how long the Cell or Row should Flash (`FlashDuration`: milliseconds, or `always`) and whether the Target is the Cell or the whole Row.

Specify **where** Flashing can apply.
Options are:

- Any Column in the Row
- One or more Columns
- One or more Data Types
- One or more Column Types (if provided)
  
  The [Column Scope Tutorial](https://www.adaptabletools.com/docs/dev-guide-columns-scope/index.md) provides more details on this topic
  

  Use the Expression Editor (and for Change Type, optionally the Query Builder) to create a Boolean Expression.
- Change Type: Relative Change Functions and value comparisons
- Observable Type: Observable Functions with curly braces — see [Observable Flashing Cells](https://www.adaptabletools.com/docs/handbook-flashing-cell-observables/index.md)

You can provide up to 3 Styles:
- Up Style - used in number and date columns
- Down Style - used in number and date columns
- Neutral Style - used in string and boolean
For each Style you can set Fore, Back and Border colours together with font properties

See [Adaptable Style](https://www.adaptabletools.com/docs/ui-tutorial-providing-adaptable-style/index.md) for more information on setting Styles

### Flashing Cell Menu Item

Flashing can be turned **on** for any Column by clicking `Add Flashing Cell` in the [Column Menu](https://www.adaptabletools.com/docs/ui-column-menu/index.md).

AdapTable can listen to 'neutral' data changes, so Flashing (and this menu item) is available in all columns

This will create a new Flashing Cell Rule with 2 features:

1. Type `Change` with an [Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md) using `ANY_CHANGE()` so cells will flash when any data changes in the column
2. Using [Default Flashing properties](https://www.adaptabletools.com/docs/handbook-flashing-cell-configuring/index.md) that were set in Flashing Options (or provided by AdapTable)

- Flashing can be turned **off** (for any Column which has a Flashing Scope of a single Column)
- This is done via the `Remove Flashing Cell` menu item which appears automatically in the [Column Menu](https://www.adaptabletools.com/docs/ui-column-menu/index.md)

## Setting UI Entitlements

The [UI Entitlements](https://www.adaptabletools.com/docs/handbook-permissioning/index.md) behaviour is as expected for `Full` and `Hidden` Access Levels.

The `ReadOnly` Entitlement behaviour is that Flashing Cells will still be applied but Users are not permitted to manage or suspend them.

### FAQ

**Can we change the colours for a Flashing Cell column?**
Yes you can choose any colours you want for both the up and down change in number and date Columns.
And you can also set the style for 'neutral' changes in text and boolean columns.

**Can we change the colour based on the row (e.g. depending on other values in the row, the flash will be different colours or duration)?**
Yes, simply create a new Flashing Cell Definition for that particular rule using an Expression.

**Can we turn on flashing for columns which don't contain numbers?**
Yes, Flashing Cell Definitions can be provided for any column or combination of columns

**Can we set the flash to remain in place until I see it?**
Yes, set the `FlashDuration` to _always_ and the Cell / Row will remain coloured until explicitly cleared by the user

**Can we flash Calculated Columns when they update?**
Yes. Calculated Columns flash when a referenced column's value changes — see [Flashing Calculated Columns](https://www.adaptabletools.com/docs/handbook-calculated-column-referencing/index.md#flashing-calculated-columns).

**What is the difference between Change and Observable Flashing?**
Change reacts to _this_ data change (any / percent / absolute move, or a value comparison).
[Observable](https://www.adaptabletools.com/docs/handbook-flashing-cell-observables/index.md) reacts to _history over a window_ (or silence) — e.g. three ticks in five minutes, or net move of more than 20

**Can we react in code when a cell flashes?**
Yes. Subscribe to **`FlashingCellDisplayed`** on [event API](https://www.adaptabletools.com/docs/technical-reference-adaptable-events/index.md) — see [Flashing Cell Displayed Event](https://www.adaptabletools.com/docs/technical-reference-flashing-cell/index.md#flashing-cell-displayed-event).
