React Data GridHighlighting Changes

Highlight changes by flashing or animating cells.

In the example above, to show changing values:

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.

In the example above:

  • All columns have enableCellChangeFlash=true so changes to the columns 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.

flashCells
Function
Flash rows, columns or individual cells.

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

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 color. To override the flash background color, override the relevant CSS class.

The example above demonstrates customising the flashing cell background color 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. 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.

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:
const [columnDefs, setColumnDefs] = useState([
    // set the cell renderer in the column definition
    { cellRenderer: "agAnimateShowChangeCellRenderer" },
]);

<AgGridReact columnDefs={columnDefs} />

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.

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:
const [columnDefs, setColumnDefs] = useState([
    // set the cell renderer in the column definition
    { cellRenderer: "agAnimateSlideCellRenderer" },
]);

<AgGridReact columnDefs={columnDefs} />