I have just had the same issue and found a clue from the ag-grid documentation. In the Cell Renderer help doc it talks about the ICellRendererComp.refresh
method:
// Mandatory - Get the cell to refresh. Return true if the refresh succeeded, otherwise return false.
// If you return false, the grid will remove the component from the DOM and create
// a new component in it's place with the new values.
refresh(params: ICellRendererParams): boolean;
and in the example further down:
// gets called whenever the user gets the cell to refresh
MyCellRenderer.prototype.refresh = function(params) {
// set value into cell again
this.eValue.innerHTML = params.valueFormatted ? params.valueFormatted : params.value;
// return true to tell the grid we refreshed successfully
return true;
};
I then implemented a refresh function on my CellRenderer
as below without changing any of the cell contents:
statusCellRenderer.prototype.refresh = function (params) {
//ensure the status cell\directive refreshes when the grid data is refreshed using deltaRowDataMode
this.params = params;
return true;
};
So in my case, I am refreshing the rowData
of the grid on a polling cycling and I didn't want the grid to keep losing the selected row. I set the deltaRowDataMode
and getRowNodeId
properties on the gridOptions
and then implemented the refresh function to make the cell re-render on a refresh. The refresh also re-renders a directive in my cell.