I would like to refresh a single cell in ag-grid. Using the gridApi.refreshCells().
This refresh is called by a piece of code that keeps track of the current and previous cell. So what i would like to do it is to update the previous cell.
I tried the following:
gridApi.refreshCells({columns: [prevColumn], rowNodes: [prevRowNode]});
Note that the prevColumn is of type "Column" and prevRowNode is of type "RowNode"
Calling this works, except that it will refresh an entire column and not just a single cell.
Also refreshing a single row is also not working, which when modifying the above to just use the rowNodes will still update the column.
Thanks you guys!
I would like to refresh a single cell in ag-grid. Using the gridApi.refreshCells().
This refresh is called by a piece of code that keeps track of the current and previous cell. So what i would like to do it is to update the previous cell.
I tried the following:
gridApi.refreshCells({columns: [prevColumn], rowNodes: [prevRowNode]});
Note that the prevColumn is of type "Column" and prevRowNode is of type "RowNode"
Calling this works, except that it will refresh an entire column and not just a single cell.
Also refreshing a single row is also not working, which when modifying the above to just use the rowNodes will still update the column.
Thanks you guys!
Share Improve this question asked Apr 23, 2021 at 21:25 FelixFelix 411 gold badge1 silver badge2 bronze badges2 Answers
Reset to default 1The best way to refresh only one cell is to use the refresh params: Instead of running:
this.params.api.refreshCells();
Get the colId from this.params.api.column
and get the rowNode using this.params.node
, and then restrict the refresh to that cell only:
this.params.api.refreshCells({
rowNodes: [this.node],
columns: [this.colId],
});
I suggest to use a cellRenderer for those cases and keep the colId and the node in a puted property.
I'm not sure exactly what you are aiming for. To refresh one cell have you tried gridApi.applyTransaction? https://www.ag-grid./javascript-grid/data-update-transactions/
Specifically the example: https://www.ag-grid./javascript-grid/data-update-transactions/#example-updating-with-transaction
If this isn't what you need, please could you provide a plunker demonstrating the issue?