Trying to select first row by default in ag-grid. As per ag-grid documents, I should be able to do this using NodeSelection Api(https://www.ag-grid.com/javascript-grid-selection/?framework=all#gsc.tab=0). But I am not able to get to node object at all.
HTML file
<div class="pulldown panel panel-default">
<div class="panel-heading">{{rulesSummaryTitle}}</div>
<ag-grid-angular #agGrid class="ag-fresh ag-bootstrap"
[gridOptions]="gridOptions"
[rowData]="rowData"
[columnDefs]="columnDefs"
[enableSorting]="true"
rowSelection="single"
[pagination]="true"
[suppressCellSelection]="true"
(gridReady)="onGridReady($event)"
(rowSelected)="onRowSelect($event)">
</ag-grid-angular>
</div>
I am calling node selection api in "onGridReady" method but errors out with error message "cant call setSelected on undefined".
public onGridReady(event: any): void {
event.api.sizeColumnsToFit();
this.gridOptions.api.node.setSelected(true);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…