行删除后如何升级/刷新ag-grid? [英] How to upgrade/refresh the ag-grid after row delete?
问题描述
我有一个ag网格,我正在尝试删除行...我能够使用拼接技术从数据源中删除该行,此后,我想刷新表。但是它显示错误。这是我用来删除行的代码
I have an ag grid where i am trying to delete a row...I am able to remove the row from data source using "splice" technique,after that i want to refresh the table.But it is showing error.This is the code which i am using to delete a row
selectedvalue={} //this holds the selected row value
rowData=[]; //this holds all the row data
onRowSelected(event) {
this.selectedvalue = event;
}
deletebtn() {
for (let i = 0; i < this.rowData.length; i++) {
if (this.selectedvalue.node.data.make === this.rowData[i].make) {
this.rowData.splice(i, 1);
this.gridOptions.api.refreshView();
}
}
}
它显示出类似错误this->无法读取未定义的属性'refreshView'...如何删除行后观看表中的更改。
It is showing erroe something like this--> Cannot read property 'refreshView' of undefined...How can watch the changes made in table after row delete.
推荐答案
编辑:此解决方案适用于3.3.x版(更新的plnkr链接)
This solution is for version 3.3.x (updated plnkr link)
您应再次将行设置为网格:拼接后为
:
You should set the rows into the grid again: after your splice:
gridOptions.api.setRowData(gridOptions.rowData)
也许这个plunkr可以帮助 https://plnkr.co/plunk / 0k4sYa
Maybe this plunkr helps https://plnkr.co/plunk/0k4sYa
ag-grid的作者在ag-grid论坛中对此进行了解释
The author of ag-grid explains this in the ag-grid forum
这篇关于行删除后如何升级/刷新ag-grid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!