I'm encountering an issue with ag-grid where I see the following warning in the console. Despite conducting some research, none of the solutions I found have resolved my problem. It appears that there may be a memory leak within my application based on information from Angular Material, but I am unable to pinpoint the exact cause.
ag-Grid: attempted to execute sizeColumnsToFit() while the grid is returning zero width. Could it be that the grid is not yet visible on the screen?
Please,
If you have any insights on how to address this issue or if you spot any errors in my code, even the smallest assistance would be greatly appreciated.
Here's what I've tried:
@HostListener('window:resize')
onResize() {
if (!this.gridApi) return;
setTimeout(() => {
this.gridApi.sizeColumnsToFit();
});
}
Or perhaps this solution might help:
afterGridReady() {
if (this.language === 'en') {
this.appgrid.columnApi.setColumnsVisible(['name'], true);
this.appgrid.columnApi.setColumnsVisible(['nameCZ'], false);
} else {
this.appgrid.columnApi.setColumnsVisible(['nameCZ'], true);
this.appgrid.columnApi.setColumnsVisible(['name'], false);
}
this.api.sizeColumnsToFit();
window.addEventListener('resize', function () {
setTimeout(function () {
this.api.sizeColumnsToFit();
});
});
}
Thank you in advance.