最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to refresh a single cell in ag-grid - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 1

The 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?

发布评论

评论列表(0)

  1. 暂无评论