【问题标题】:angular ag-grid editable cell issue角度 ag-grid 可编辑单元格问题
【发布时间】: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 中创建一个最小的可重现应用程序。

标签: angular ag-grid


【解决方案1】:

您可以通过 rows 变量访问您的数据。

例如:

this.rows.forEach((row) => {
    console.log('-- row data --', row);
});

请查看ag-grid Update 文档。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-27
    • 2019-04-22
    • 2019-01-10
    • 2020-02-19
    • 2021-09-10
    • 1970-01-01
    • 2017-06-17
    • 2021-03-14
    相关资源
    最近更新 更多