---
title: "Highlighting Changes"
framework: javascript
version: "36.1.0"
---

# Highlighting Changes

Highlight changes by flashing or animating cells.

#### Animated Flashing Cells

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowApiModule,
  CellStyleModule,
  ClientSideRowModelModule,
  HighlightChangesModule,
]);

let gridApi: GridApi;

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

const gridOptions: GridOptions = {
  columnDefs: [
    { field: "a", enableCellChangeFlash: true },
    { field: "b", enableCellChangeFlash: true },
    { field: "c", cellRenderer: "agAnimateShowChangeCellRenderer" },
    { field: "d", cellRenderer: "agAnimateShowChangeCellRenderer" },
    { field: "e", cellRenderer: "agAnimateSlideCellRenderer" },
    { field: "f", cellRenderer: "agAnimateSlideCellRenderer" },
  ],
  defaultColDef: {
    flex: 1,
    cellClass: "align-right",
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
  onGridReady: () => {
    const updateValues = () => {
      const rowCount = gridApi!.getDisplayedRowCount();
      // pick 2 cells at random to update
      for (let i = 0; i < 2; i++) {
        const row = Math.floor(window.agRandom() * rowCount);
        const rowNode = gridApi!.getDisplayedRowAtIndex(row)!;
        const col = ["a", "b", "c", "d", "e", "f"][
          Math.floor(window.agRandom() * 6)
        ];
        rowNode.setDataValue(col, Math.floor(window.agRandom() * 10000));
      }
    };

    setInterval(updateValues, 250);
  },
};

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 145045) % 10000),
      b: Math.floor(((i + 323) * 543020) % 10000),
      c: Math.floor(((i + 323) * 305920) % 10000),
      d: Math.floor(((i + 323) * 204950) % 10000),
      e: Math.floor(((i + 323) * 103059) % 10000),
      f: Math.floor(((i + 323) * 468276) % 10000),
    });
  }

  return rowData;
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);
```

[Live example: Animated Flashing Cells](https://www.ag-grid.com/examples/change-cell-renderers/animated-flashing-cells/typescript)

The example above shows changing values:

- Columns A and B use [Flashing Cells](https://www.ag-grid.com/javascript-data-grid/change-cell-renderers/#flashing-cells).
- Columns C and D use the [Animate Show Change](https://www.ag-grid.com/javascript-data-grid/change-cell-renderers/#animate-show-changed-cells) cell renderer.
- Columns E and F use the [Animate Slide Cell](https://www.ag-grid.com/javascript-data-grid/change-cell-renderers/#animate-slide-cells) cell renderer.

## Flashing Cells

You can trigger cells to flash either though the Grid API or by enabling cells to flash when the data changes.

### Enable Flashing on Data Change

Set Column attribute `enableCellChangeFlash=true` to flash the cells when data changes.

#### Flashing Data Changes

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowApiModule,
  HighlightChangesModule,
  CellStyleModule,
  ClientSideRowModelModule,
]);

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: [
    { field: "a" },
    { field: "b" },
    { field: "c" },
    { field: "d" },
    { field: "e" },
    { field: "f" },
  ],
  defaultColDef: {
    flex: 1,
    cellClass: "align-right",
    enableCellChangeFlash: true,
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
};

function onUpdateSomeValues() {
  const rowCount = gridApi!.getDisplayedRowCount();
  // pick 20 cells at random to update
  for (let i = 0; i < 20; i++) {
    const row = Math.floor(window.agRandom() * rowCount);
    const rowNode = gridApi!.getDisplayedRowAtIndex(row)!;
    const col = ["a", "b", "c", "d", "e", "f"][i % 6];
    rowNode.setDataValue(col, Math.floor(window.agRandom() * 10000));
  }
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 25435) % 10000),
      b: Math.floor(((i + 323) * 23221) % 10000),
      c: Math.floor(((i + 323) * 468276) % 10000),
      d: 0,
      e: 0,
      f: 0,
    });
  }

  return rowData;
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onUpdateSomeValues = onUpdateSomeValues;
}
```

[Live example: Flashing Data Changes](https://www.ag-grid.com/examples/change-cell-renderers/flashing-data-changes-coldef/typescript)

In the example above:

- All columns have `enableCellChangeFlash=true` so changes to the cell values will flash the cell.
- Clicking **Update Some Data** will randomly update some data. The grid will then flash the cells where data has changed.

To change the length of the effect, use the grid options `cellFlashDuration` and `cellFadeDuration`.

By default, value changes caused by updates to column filters are not highlighted with cell flashing. This behaviour can be toggled by enabling the grid option `allowShowChangeAfterFilter`.

### Flash Cells using the API

Alternatively flash cells using the grid API `flashCells(params)`. The params object takes a list of columns and rows to flash, together with the `flashDuration` and the `fadeDuration` values.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `flashCells` | `Function` |  |  | Flash rows, columns or individual cells. Module: [`HighlightChangesModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |

When calling `flashCells()`, pass the `flashDuration` and `fadeDuration` values (in milliseconds) as params to change the duration of cell flashing.

#### Flashing Data Changes

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  HighlightChangesModule,
  RowApiModule,
  CellStyleModule,
  ClientSideRowModelModule,
]);

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: [
    { field: "a" },
    { field: "b" },
    { field: "c" },
    { field: "d" },
    { field: "e" },
    { field: "f" },
  ],
  defaultColDef: {
    flex: 1,
    cellClass: "align-right",
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
};

function onFlashOneCell() {
  // pick fourth row at random
  const rowNode = gridApi!.getDisplayedRowAtIndex(4)!;
  // pick 'c' column
  gridApi!.flashCells({ rowNodes: [rowNode], columns: ["c"] });
}

function onFlashTwoColumns() {
  // flash whole column, so leave row selection out
  gridApi!.flashCells({ columns: ["c", "d"] });
}

function onFlashTwoRows() {
  // pick fourth and fifth row at random
  const rowNode1 = gridApi!.getDisplayedRowAtIndex(4)!;
  const rowNode2 = gridApi!.getDisplayedRowAtIndex(5)!;
  // flash whole row, so leave column selection out
  gridApi!.flashCells({ rowNodes: [rowNode1, rowNode2] });
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 25435) % 10000),
      b: Math.floor(((i + 323) * 23221) % 10000),
      c: Math.floor(((i + 323) * 468276) % 10000),
      d: 0,
      e: 0,
      f: 0,
    });
  }

  return rowData;
}

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onFlashOneCell = onFlashOneCell;
  (<any>window).onFlashTwoColumns = onFlashTwoColumns;
  (<any>window).onFlashTwoRows = onFlashTwoRows;
}
```

[Live example: Flashing Data Changes](https://www.ag-grid.com/examples/change-cell-renderers/flashing-data-changes/typescript)

In the example above, all three buttons use the `flashCells(params)` API. Note the following:

- Clicking **Flash One Cell** uses parameters with one column and one row to flash the intersecting cell.
- Clicking **Flash Two Rows** uses parameters consisting of two row nodes, causing those rows to flash.
- Clicking **Flash Two Columns** uses parameters consisting of two columns, causing those columns to flash.

### Customise Flash Colour

Each time the cell value is changed, the grid adds the CSS class `ag-cell-data-changed` for 500ms by default, and then the CSS class `ag-cell-data-changed-animation` for 1,000ms by default. The grid-provided themes use this to apply a background colour. To override the flash background colour, override the relevant CSS class.

#### Customising Flashing

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowApiModule,
  HighlightChangesModule,
  CellStyleModule,
  ClientSideRowModelModule,
]);

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: [
    { field: "a" },
    { field: "b" },
    { field: "c" },
    { field: "d" },
    { field: "e" },
    { field: "f" },
  ],
  defaultColDef: {
    flex: 1,
    cellClass: "align-right",
    enableCellChangeFlash: true,
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
};

function onUpdateSomeValues() {
  const rowCount = gridApi!.getDisplayedRowCount();
  // pick 20 cells at random to update
  for (let i = 0; i < 20; i++) {
    const row = Math.floor(window.agRandom() * rowCount);
    const rowNode = gridApi!.getDisplayedRowAtIndex(row)!;
    const col = ["a", "b", "c", "d", "e", "f"][i % 6];
    rowNode.setDataValue(col, Math.floor(window.agRandom() * 10000));
  }
}

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 25435) % 10000),
      b: Math.floor(((i + 323) * 23221) % 10000),
      c: Math.floor(((i + 323) * 468276) % 10000),
      d: 0,
      e: 0,
      f: 0,
    });
  }

  return rowData;
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onUpdateSomeValues = onUpdateSomeValues;
}
```

[Live example: Customising Flashing](https://www.ag-grid.com/examples/change-cell-renderers/customising-flashing/typescript)

The example above demonstrates customising the flashing cell background colour using the `--ag-value-change-value-highlight-background-color` CSS variable.

## Animated Cell Renderers

Interesting animations for data changes can be achieved using [Cell Components](https://www.ag-grid.com/javascript-data-grid/component-cell-renderer/). You can create your own or use one of the provided Show Change Cell Components. The grid provides two such components out of the box.

### Animate Show Changed Cells

The difference between the previous and new value is temporarily shown beside the new value and is then faded out. This difference is shown in either green or red, for an increase or decrease in value respectively, alongside an arrow indicating the direction of change.

#### Animate Show Change Renderer

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  TextEditorModule,
  ValueParserParams,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextEditorModule,
  RowApiModule,
  CellStyleModule,
  ClientSideRowModelModule,
  HighlightChangesModule,
]);

const columnDefs: ColDef[] = [
  {
    headerName: "Editable A",
    field: "a",
    editable: true,
    valueParser: numberValueParser,
  },
  {
    headerName: "Editable B",
    field: "b",
    editable: true,
    valueParser: numberValueParser,
  },
  {
    headerName: "API C",
    field: "c",
    minWidth: 135,
    valueParser: numberValueParser,
    cellRenderer: "agAnimateShowChangeCellRenderer",
  },
  {
    headerName: "API D",
    field: "d",
    minWidth: 135,
    valueParser: numberValueParser,
    cellRenderer: "agAnimateShowChangeCellRenderer",
  },
  {
    headerName: "Total",
    valueGetter: "data.a + data.b + data.c + data.d",
    minWidth: 135,
    cellRenderer: "agAnimateShowChangeCellRenderer",
  },
  {
    headerName: "Average",
    valueGetter: "(data.a + data.b + data.c + data.d) / 4",
    minWidth: 135,
    cellRenderer: "agAnimateShowChangeCellRenderer",
  },
];

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: columnDefs,
  defaultColDef: {
    minWidth: 105,
    flex: 1,
    cellClass: "align-right",
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
};

function numberValueParser(params: ValueParserParams) {
  return Number(params.newValue);
}

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

function onUpdateSomeValues() {
  const rowCount = gridApi!.getDisplayedRowCount();
  for (let i = 0; i < 10; i++) {
    const row = Math.floor(window.agRandom() * rowCount);
    const rowNode = gridApi!.getDisplayedRowAtIndex(row)!;
    rowNode.setDataValue("c", Math.floor(window.agRandom() * 10000));
    rowNode.setDataValue("d", Math.floor(window.agRandom() * 10000));
  }
}

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 25435) % 10000),
      b: Math.floor(((i + 323) * 23221) % 10000),
      c: Math.floor(((i + 323) * 468276) % 10000),
      d: 0,
    });
  }

  return rowData;
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onUpdateSomeValues = onUpdateSomeValues;
}
```

[Live example: Animate Show Change Renderer](https://www.ag-grid.com/examples/change-cell-renderers/animate-show-change-renderer/typescript)

The example above demonstrates the following:

- Columns A, B are editable.
- Columns C and D are updated via clicking the button.
- Changes to any of the first 4 columns results in animations in the Total and Average column.
- This can be set as a cell renderer in the column definitions:

```js
const gridOptions = {
    columnDefs: [
        // set the cell renderer in the column definition
        { cellRenderer: "agAnimateShowChangeCellRenderer" },
    ],

    // other grid options ...
}
```

### Animate Slide Cells

The previous value is shown in a faded fashion and slides, giving a ghosting effect as the old value fades and slides away.

#### Animate Slide Renderer

```ts
import {
  CellStyleModule,
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  HighlightChangesModule,
  ModuleRegistry,
  RowApiModule,
  TextEditorModule,
  ValueParserParams,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextEditorModule,
  RowApiModule,
  CellStyleModule,
  ClientSideRowModelModule,
  HighlightChangesModule,
]);

const columnDefs: ColDef[] = [
  {
    headerName: "Editable A",
    field: "a",
    editable: true,
    valueParser: numberValueParser,
  },
  {
    headerName: "Editable B",
    field: "b",
    editable: true,
    valueParser: numberValueParser,
  },
  {
    headerName: "API C",
    field: "c",
    minWidth: 135,
    valueParser: numberValueParser,
    cellRenderer: "agAnimateSlideCellRenderer",
  },
  {
    headerName: "API D",
    field: "d",
    minWidth: 135,
    valueParser: numberValueParser,
    cellRenderer: "agAnimateSlideCellRenderer",
  },
  {
    headerName: "Total",
    valueGetter: "data.a + data.b + data.c + data.d",
    minWidth: 135,
    cellRenderer: "agAnimateSlideCellRenderer",
  },
  {
    headerName: "Average",
    valueGetter: "(data.a + data.b + data.c + data.d) / 4",
    minWidth: 135,
    cellRenderer: "agAnimateSlideCellRenderer",
  },
];

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: columnDefs,
  defaultColDef: {
    minWidth: 105,
    flex: 1,
    cellClass: "align-right",
    valueFormatter: (params) => {
      return formatNumber(params.value);
    },
  },
  rowData: createRowData(),
};

function numberValueParser(params: ValueParserParams) {
  return Number(params.newValue);
}

function formatNumber(number: number) {
  return Math.floor(number).toLocaleString();
}

function onUpdateSomeValues() {
  const rowCount = gridApi!.getDisplayedRowCount();
  for (let i = 0; i < 10; i++) {
    const row = Math.floor(window.agRandom() * rowCount);
    const rowNode = gridApi!.getDisplayedRowAtIndex(row)!;
    rowNode.setDataValue("c", Math.floor(window.agRandom() * 10000));
    rowNode.setDataValue("d", Math.floor(window.agRandom() * 10000));
  }
}

function createRowData() {
  const rowData = [];

  for (let i = 0; i < 20; i++) {
    rowData.push({
      a: Math.floor(((i + 323) * 25435) % 10000),
      b: Math.floor(((i + 323) * 23221) % 10000),
      c: Math.floor(((i + 323) * 468276) % 10000),
      d: 0,
    });
  }

  return rowData;
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).onUpdateSomeValues = onUpdateSomeValues;
}
```

[Live example: Animate Slide Renderer](https://www.ag-grid.com/examples/change-cell-renderers/animate-slide-renderer/typescript)

The example above demonstrates the following:

- Columns A, B are editable.
- Columns C and D are updated via clicking the button.
- Changes to any of the first 4 columns results in animations in the Total and Average column.
- This can be set as a cell renderer in the column definitions:

```js
const gridOptions = {
    columnDefs: [
        // set the cell renderer in the column definition
        { cellRenderer: "agAnimateSlideCellRenderer" },
    ],

    // other grid options ...
}
```
