带有 deltaRowDataMode 的 ag-grid cellRendering

bod*_*dtx 8 updates cellrenderer ag-grid

嗨,当我更新所有数据时,我有一些具有自定义渲染的单元格,deltaRowDataMode不会处理我的 cutom 单元格渲染的更改。更新行的其他单元格已正确更新。

如何给 ag 网格提供线索以正确比较此自定义单元格

sar*_*rin 4

我刚刚遇到了同样的问题,并从 ag-grid 文档中找到了线索。在Cell Renderer帮助文档中,它讨论了该ICellRendererComp.refresh方法:

// 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;
Run Code Online (Sandbox Code Playgroud)

在下面的例子中:

// 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;
};
Run Code Online (Sandbox Code Playgroud)

CellRenderer然后,我在不更改任何单元格内容的情况下实现了刷新功能,如下所示:

statusCellRenderer.prototype.refresh = function (params) {
    //ensure the status cell\directive refreshes when the grid data is refreshed using deltaRowDataMode
    this.params = params;
    return true;
};
Run Code Online (Sandbox Code Playgroud)

因此,就我而言,我rowData在轮询循环中刷新网格,并且我不希望网格继续丢失所选行。我设置了deltaRowDataModegetRowNodeId属性gridOptions,然后实现了刷新功能,使单元格在刷新时重新渲染。刷新还会在我的单元格中重新呈现指令。