ag grid clear data code example
Example: How to add new row to a particular index of a ag grid using angular 7
addRow(){
// Assuming newRow is an object, such as {"slNo": this.index,"id":3, "rank":1};
rowData.splice(targetIndex, 0, newRow);
this.gridApi.setRowData(rowData); // optional
}