javascript - How to set the first row selected by default in ag grid (Angular) - Stack Overflow

How to set the ag-grid first row selected by default in angular.here's the code:appappponent.ts

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 badges
Add a ment  | 

1 Answer 1

Reset to default 2

You need to have a property to uniquely identify a record (eg. id) for this.

  1. Provide this function in your template.
[getRowNodeId]="_getRowNodeId"
_getRowNodeId(data) {
  return data.id;
}
  1. Provide this id for each object of rowData

  2. 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745042894a4607918.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信