ag-Grid 行不删除
ag-Grid row not deleting
我正在尝试从我的 ag-Grid 中删除一行,如下所示:
let alertRow : RowNode = this.gridApi.getRowNode(rowIndex);
console.log(alertRow);
this.gridApi.updateRowData({remove: [alertRow]});
它给我这个错误:
ag-Grid: could not find data item as object was not found
我可以在控制台中看到 RowNode
是正确的节点并且存在。我也可以使用 updateRowData()
正常添加新行,但尝试删除会出现此错误。
我在 Angular 6 组件中使用 ag-Grid。
为什么删除不起作用?
将updateRowData({remove:[alerRow]})
替换为
updateRowData({remove:[alertRow.data]}))
updated doc
... If you are not using ID's, then the grid will match the rows based on object reference.
不完全确定这是正确的 place/way 添加到 , but if you're using the getSelectedNodes 方法以获取您要删除的数据,语法略有不同(需要索引到所选节点)。
(均假定您使用的是单行选择)
getSelectedNodes
const selectedNode = this.gridApi.getSelectedNodes();
this.gridApi.updateRowData({ remove: [selectedNode[0].data] });
而且,为了"completeness",
getSelectedRows(尽管 API 建议使用 getSelectedNodes
)
const selectedRow = this.gridApi.getSelectedRows();
this.gridApi.updateRowData({ remove: selectedRow });
如果你使用vue.js,你可以使用这行代码:
获取 select 行,const selectedRow = this.gridApi.getFocusedCell()
通过select行获取节点 const node = this.gridApi.getRowNode(selectedRow.rowIndex)
ApplyTransaction 通过节点的数据删除节点。 this.gridApi.applyTransaction({ remove: [node.data] })
我正在尝试从我的 ag-Grid 中删除一行,如下所示:
let alertRow : RowNode = this.gridApi.getRowNode(rowIndex);
console.log(alertRow);
this.gridApi.updateRowData({remove: [alertRow]});
它给我这个错误:
ag-Grid: could not find data item as object was not found
我可以在控制台中看到 RowNode
是正确的节点并且存在。我也可以使用 updateRowData()
正常添加新行,但尝试删除会出现此错误。
我在 Angular 6 组件中使用 ag-Grid。
为什么删除不起作用?
将updateRowData({remove:[alerRow]})
替换为
updateRowData({remove:[alertRow.data]}))
updated doc
... If you are not using ID's, then the grid will match the rows based on object reference.
不完全确定这是正确的 place/way 添加到
(均假定您使用的是单行选择)
getSelectedNodes
const selectedNode = this.gridApi.getSelectedNodes();
this.gridApi.updateRowData({ remove: [selectedNode[0].data] });
而且,为了"completeness",
getSelectedRows(尽管 API 建议使用 getSelectedNodes
)
const selectedRow = this.gridApi.getSelectedRows();
this.gridApi.updateRowData({ remove: selectedRow });
如果你使用vue.js,你可以使用这行代码:
获取 select 行,
const selectedRow = this.gridApi.getFocusedCell()
通过select行获取节点 const node =
this.gridApi.getRowNode(selectedRow.rowIndex)
ApplyTransaction 通过节点的数据删除节点。
this.gridApi.applyTransaction({ remove: [node.data] })