Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ag-grid cellRendering with deltaRowDataMode

Hi I have some cells with custom rendering when I update the all data, the deltaRowDataMode does not hnadle the change of my cutsom cell rendering. Other cells of the updated row are correctly updated.

How can I give a clue to ag grid to compare correctly this custom cell

like image 925
bodtx Avatar asked Apr 11 '18 11:04

bodtx


1 Answers

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.

like image 107
sarin Avatar answered Nov 06 '22 15:11

sarin