Vin*_*hen 10 infinite ag-grid angular
我有一个像这样的聚合组件:
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();
});
}
};
Run Code Online (Sandbox Code Playgroud)
aggrid首次加载时,显示正常。如果我按下一页,我收到此错误:
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."
Run Code Online (Sandbox Code Playgroud)
有没有例子可以参考?我四处搜寻,但似乎每个人都做得很好,没有这个问题。
顺便说一句:我正在使用angular 8
,aggrid 22.1.1
noa*_*700 13
正如 @Vincemt Chen 评论中所述
感谢您的回答。这对我来说是一个 valueFormatter 问题。如果我从列定义中删除 valueFormatter,一切都会正常。当我检查 chrome 控制台时,我看到格式化程序函数未定义单元格值。我不知道如何修复它,所以我删除了所有 valueFormatter。之后一切都很好。
这也发生在我身上,所以valueFormatter
我没有删除哪个有用的,而是添加了检查 if params.value
is undefined
。例如:
{
headerName: "first cell",
field: "first field",
valueFormatter: (params) => {
if(!params.value) return 'ERROR';
...your original code...
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20452 次 |
最近记录: |