【发布时间】:2020-06-14 16:12:48
【问题描述】:
在我的 Angular 8 应用程序中更新 ag-grid 中的单元格时遇到问题。请在下面找到代码:
this.columns = [
{ headerName: '', field: 'enabled', width: 30, headerCheckboxSelection: true, checkboxSelection: true },
{ headerName: 'First Name', field: 'firstName', width: 100 },
{ headerName: 'Address', field: 'address', editable: true, width: 100 },
{ headerName: 'Address1', field: 'address1', editable: true, width: 70 }
];
this.rows = [
{"first name1", "address", "address1"},
{"first name2", "address", "address1"}
];
上面的代码允许我更新地址和地址 1 字段,但是当我尝试获取行数据时,它使用的是旧值。请在下面找到我的代码以获取数据:
this.agGrid.api.forEachNode((node) => {
console.log('-- the node data --', node.data);
});
我需要进行哪些更改才能从 ag-grid 获取更新的数据。
谢谢
【问题讨论】:
-
你处理过
getRowNodeIdcellEditingStopped事件吗?分享您的整个代码或在 plunk 上重现您的问题。 -
没有,以上方法我都没有处理。上面的代码就是我现在所拥有的。您能否在 plunk 上分享您的。
-
据我尝试,当我使用
forEachNode()方法进行迭代时,它正在为我更新。共享显示 ag-grid 表的组件文件(TS 和 HTML)。如果可能的话,在 Stackblitz 中创建一个最小的可重现应用程序。