【问题标题】:ag-grid cellRendering with deltaRowDataMode使用 deltaRowDataMode 进行 ag-grid cellRendering
【发布时间】:2018-09-21 06:58:08
【问题描述】:

您好,我有一些带有自定义渲染的单元格 当我更新所有数据时,deltaRowDataMode 不会改变我的 cutsom 单元格渲染。更新行的其他单元格已正确更新。

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

【问题讨论】:

  • 请分享sn-p更多权限

标签: updates ag-grid cellrenderer


【解决方案1】:

我刚刚遇到了同样的问题,并从 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;

在下面的例子中:

// 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;
};

然后我在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;
};

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

【讨论】:

  • 这对我来说效果很好。在我的情况下,我试图通过 GridOptions 中的 isFullWidthCell 回调将一行切换为全宽单元格渲染器。我发现使用通常的gridAPI.refreshCells() 并没有初始化全宽单元格渲染器,而是使用gridAPI.redrawRows() 来初始化和拆除全宽单元格渲染器。见Redraw Rows
猜你喜欢
  • 2018-10-09
  • 1970-01-01
  • 2019-03-02
  • 1970-01-01
  • 2016-05-11
  • 1970-01-01
  • 2020-03-31
  • 2020-09-26
  • 1970-01-01
相关资源
最近更新 更多