I am trying to set the focus to the first editable cell in my grid and am getting this error "TypeError: Cannot read property 'setFocusedCell' of undefined".
I'm calling setFocusedCell in ngOnInit in my ag-grid-angular component. Here is a snippet:
constructor(private mcService: MonteCarloService) {
this.gridOptions = <GridOptions>{
rowData: MCInputGridComponent.createRowData(),
columnDefs: MCInputGridComponent.createColumnDefs()
};
}
ngOnInit() {
this.gridOptions.api.setFocusedCell(1, "histDataType", null);
}
I've defined the columns and set some data via the constructor methods. Below are the column definitions.
private static createColumnDefs() {
return [
{
colKey: "sprint#",
headerName: "Sprint #",
field: "sprint",
width: 80,
editable: false
},
{
colKey: "histDataType",
headerName: "Velocity",
field: "histDataType",
cellEditorFramework: NumericEditorComponent,
editable: true,
width: 102
}
];
}