I just started implementing ag-grid in my application.
I want to configure it programatically, I want to put all agGrid configuration related code into a separate function in Helper.ts.
I want to use this function in all my application to configure agGrid so that I can manage the agGrid from a single place.
I am wrote below code for that, but looks like it is not working:
Helper Class Code:
public ConfigureAgGrid(gridOptions: GridOptions): GridOptions {
rowSelection: 'multiple',
gridOptions.columnDefs = columnDefs;
gridOptions.rowData = data;
onSelectionChanged: this.onSelectionChanged,
gridOptions.api.sizeColumnsToFit();
return gridOptions;
}
Component Code:
onGridReady(gridOptions: GridOptions) {
this.helperService.ConfigureAgGrid(gridOptions);
}
From the ag-grid website Sometimes the gridReady grid event can fire before the Angular component is ready to receive it, so in an Angular environment its safer to rely on AfterViewInit instead before using the API.