Check out example codes for "How to add new row to a particular index of a ag grid using angular 7". It will help you in understanding the concepts better.

Code Example 1

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
}

Learn ReactJs, React Native from akashmittal.com