I am trying to add a new row into a particular index of a ag-grid but i am unable to add it. when i try to add it's adding entire things in grid again and creating duplicate along with the new row. Please help me on this.
I am getting the index of the selected row and i want to add new row just below the selected row.
Code for getting index of a selected row.
onRowClick(event: any): void {
this.index = event.rowIndex;
}
and i am calling this in angular-ag-grid as below:
(rowClicked)="onRowClick($event)"
And for adding row below is my try:
addRow(){
this.lst.push( {"slNo": this.index,"id":3, "rank":1,
this.gridApi.updateRowData({
add: this.lst,
addIndex: index
});
}
Here lst is the object model which contain all rows in the arraylist format and i am pushing new row to that array. And index i am getting from the onRowClick event.
When i try in above method it's duplicating the value those already present in the array along with the new row.
Please help me !