Search code examples
ag-grid

ag grid: possible to customize when cells flash?


enableCellChangeFlash is used to flash cells that get updated content. However, Im using valueFormatters on a couple of columns and I only want to flash the cell contents if the rendered content changes instead of the underlying value.

Example: I have prices which are floats, e.g.: 3.2321393. I fix this to 2 decimals (.e.g; 3.23) . Now I only want to flash the cell if the rendered value changes, say 3.24, but not when the underlying value changes, say 3.23214 without a visible change.

Is this possible?


Solution

  • @ViqMontana's answer pointed in the right direction, but would require calling flashCells for every cell that needed updating.

    Instead I've ported the code in the equals function that can optionally be passed to a column definition.

    // Equals function to check if cell value has *visibly* changed. Only then the cell will flash
    function equalsCellFN(valueA, valueB) {
      const valueFormatter = this.valueFormatter;
      const newFormattedValue = valueFormatter ? valueFormatter({ value: valueA }) : valueA;
      const oldFormattedValue = valueFormatter ? valueFormatter({ value: valueB }) : valueB;
      return oldFormattedValue === newFormattedValue
    }