I am using the ag-grid API in an Angular 2 app, inside the ngOnInit method.
In the onGridReady event like mentioned in this post, the API is accessible and things work fine.
However, I need to call the API in one of the following methods as well:
- onRowDataChanged
- onNewColumnsLoaded
- onModelUpdated
This is not working because the API is undefined. In addition, for some reason I can also call the API in the onCellDoubleClicked and onCellClicked events.
This seem to be a bug. Does anyone know what is going on?
Please see the code bellow:
ngOnInit() {
this.gridOptions = <GridOptions>{
onGridReady: function (param) {
param.api.sizeColumnsToFit(); // works fine
},
onCellDoubleClicked: function (param) {
param.api.sizeColumnsToFit(); // works fine
},
onRowDataChanged: function (param) {
param.api.sizeColumnsToFit(); // API is undefined
},
};
}