How to upgrade/refresh the ag-grid after row delete?

Raja Reddy picture Raja Reddy · Feb 10, 2016 · Viewed 58.2k times · Source

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();
        }
    }
}

It is showing erroe something like this--> Cannot read property 'refreshView' of undefined...How can watch the changes made in table after row delete.

Answer

Moises Sacal picture Moises Sacal · Feb 29, 2016

Edit: 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)

Maybe this plunkr helps https://plnkr.co/plunk/0k4sYa

The author of ag-grid explains this in the ag-grid forum The forum no longer exist