0
votes

My grid options are:

   defaultColDef: {
      sortable: true,
      filter: false,
      resizable: true,
      cellStyle: function(params) {
        if (params.node.data.missing && params.node.data.missing.indexOf(params.column.colId) >= 0) {
          return { background: '#fe7979' };
        } else {
          return null;
        }
      },
    }

This works fine. If we're painting the column of an item that is in params.node.missing, it paints the background red. Otherwise, it uses the default color

The caveat is that params.node.missing changes via external validation. The next time the cellstyle callback comes around, it does realize that it should not be painted red anymore. However, when I return null, it seems to leave the background as-is (eg red). Am I missing something?

Note: I got into explicitly returning the cell color I wanted but then that starts to muck up colors when a row is selected.

1

1 Answers

1
votes

Instead of returning the complete style as null set only the background color as null.

    defaultColDef: {
      sortable: true,
      filter: false,
      resizable: true,
      cellStyle: function(params) {
        let color = null;
        if (
          params.node.data.missing &&
          params.node.data.missing.indexOf(params.column.colId) >= 0
        ) {
          color = '#fe7979';
        }
        return { background: color };
      }
    };