Issue
I have stuck in one problem, i want to add new row to the ag grid for specified row(i.e i just want to add a new row just below the selected row in a ag grid)
As a first step i am trying to get the index number of a selected row. But unable to get the index of a selected row.
Below is the code that i have tried to print index in ag grid.
In columnDefs:
public columnDefs = [
{headerName: 'index', valueGetter: (args) => this._getIndexValue(args), field: 'index',editable: true, width:100}]
_getIndexValue(args: ValueGetterParams): any {
return args.node.rowIndex;
}
But this code working as expected and i am able to see the index column in ag grid.But how do i get the index for particular selected row?
I am using below code to get the selected row.
this.gridApi.getSelectedRows();
But no where i am getting the index of that row.
Please help me in this.
Solution
From the answer I linked, you can use (rowClicked)="onRowClick($event)"
on the ag-grid-angular
element and in your .ts
have:
onRowClick(event: any): void {
console.log(event.rowIndex);
}
Check stackblitz example.
Answered By - Milo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.