gpt4 book ai didi

ag-grid - ImmutableService 需要实现 getRowNodeId() 回调,您的行数据需要 ID

转载 作者:行者123 更新时间:2023-12-04 12:25:36 25 4
gpt4 key购买 nike

我试着添加

[deltaRowDataMode]="true"

到我的网格并调用
this.gridApi.setRowData(this.rowData);

但代码抛出错误
ag-Grid: ImmutableService requires getRowNodeId() callback to be implemented, your row data need IDs!

push../projects/secdo-infra-lib/node_modules/ag-grid-community/dist/lib/rowModels/clientSide/immutableService.js.ImmutableService.createTransactionForRowData @ immutableService.js:38
push../projects/secdo-infra-lib/node_modules/ag-grid-community/dist/lib/gridApi.js.GridApi.setRowData @ gridApi.js:151

在网上查找这个我读到如果没有设置 getRowNodeId 是自动生成的,所以我不明白为什么会抛出错误。

最佳答案

来自 docs

For the deltaRowDataMode to work, you must be providing ID's for the row nodes by implementing the getRowNodeId() callback.

The grid works out the delta changes with the following rules:

IF the ID for the new item doesn't have a corresponding item already in the grid THEN it's an 'add'.
IF the ID for the new item does have a corresponding item in the grid THEN compare the object references. If the object references are different, it's an update, otherwise it's nothing (excluded from the transaction).
IF there are items in the grid for which there are no corresponding items in the new data, THEN it's a 'remove'.



您可以实现 getRowNodeId()以某种方式为每一行返回唯一的 id。例如
this.getRowNodeId = function(data) {
return data.id; //id is a field here
};

本官方 example有更多细节

关于ag-grid - ImmutableService 需要实现 getRowNodeId() 回调,您的行数据需要 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54727572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com