How to set the ag-grid first row selected by default in angular.
here's the code: https://stackblitz.com/edit/ag-grid-angular-hello-world-xabqct?file=src/app/app.component.ts
I want the first row is selected by default when opening the application.
How to set the ag-grid first row selected by default in angular.
here's the code: https://stackblitz.com/edit/ag-grid-angular-hello-world-xabqct?file=src/app/app.component.ts
I want the first row is selected by default when opening the application.
You need to have a property to uniquely identify a record (eg. id) for this.
[getRowNodeId]="_getRowNodeId"
_getRowNodeId(data) {
return data.id;
}
Provide this id for each object of rowData
In onGridReady, call gridApi's getRowNode(id).selectThisNode(true) to select the first record.
this.gridApi.getRowNode(1).selectThisNode(true);
Check this updated StackBlitz for reference.