How to set the ag-grid first row selected by default in angular.
here's the code: /app/appponent.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./edit/ag-grid-angular-hello-world-xabqct?file=src/app/app.ponent.ts
I want the first row is selected by default when opening the application.
Share Improve this question asked Jan 20, 2020 at 4:29 ABCABC 8326 gold badges20 silver badges45 bronze badges1 Answer
Reset to default 2You need to have a property to uniquely identify a record (eg. id
) for this.
- Provide this function in your template.
[getRowNodeId]="_getRowNodeId"
_getRowNodeId(data) {
return data.id;
}
Provide this
id
for each object ofrowData
In
onGridReady
, callgridApi
'sgetRowNode(id).selectThisNode(true)
to select the first record.
this.gridApi.getRowNode(1).selectThisNode(true);
Check this updated StackBlitz for reference.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745042894a4607918.html
评论列表(0条)