I have a aggrid component like this:
private gridOptions = {
columnDefs: this.columnDefs,
frameworkComponents: { buttonRenderer: ButtonRenderer},
pagination: true,
paginationPageSize: 20,
cacheBlockSize: 20,
// server side paging
rowModelType: 'infinite',
datasource: this.dataSource
};
private dataSource: IDatasource = {
getRows: (params: IGetRowsParams) => {
var query = { startrow: params.startRow,
endrow: params.endRow,
company_name: this.companyName,
company_address: this.companyAddress,
company_capital: this.companyCapital
};
this.http.post(environment.api_url + "/register/search",query).subscribe((results:any) => {
params.successCallback(results.data, results.totalRecords);
this.gridApi.refresh();
});
}
};
When aggrid first loaded, it shows normally. If I press next page, I got this error:
ERROR Error: "ag-Grid: cannot get grid to draw rows when it is in the middle
of drawing rows. Your code probably called a grid API method while the grid
was in the render stage. To overcome this, put the API call into a timeout,
eg instead of api.refreshView(), call setTimeout(function()
{api.refreshView(),0}). To see what part of your code that caused the
refresh check this stacktrace."
Is there any example to reference? I searched around but everyone seems to do fine without this problem.
BTW: I am using angular 8
,aggrid 22.1.1