我一直在尝试使用Ag-grid实现客户端无限滚动。不幸的是,它引发了错误并且根本没有加载数据。没有无限滚动脚本,一切工作正常。添加无限滚动脚本后,它将无法正常工作。
错误
ag-grid: cannot get grid to draw rows when it is in the middle of drawing rows.
有专家建议吗?
这里是我如何创建组件的示例
TS
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
this.dataService.getData().subscribe(
=> data {
var dataSource = {
rowCount: null,
getRows: function(params) {
console.log("asking for " + params.startRow + " to " + params.endRow);
setTimeout(function() {
var rowsThisPage = data.slice(params.startRow, params.endRow);
var lastRow = -1;
if (data.length <= params.endRow) {
lastRow = data.length;
}
params.successCallback(rowsThisPage, lastRow);
}, 500);
}
};
params.api.setDatasource(dataSource);
});
}
});
ngAfterViewInit():void {
this.gridOption.api.setColumnDef([
{
headerName: "Name",
field: "Name",
valueGetter:(params) => params.data.name.en;
}
{
headerName: "Age",
field: "Age",
valueGetter:(params) => params.data.age;
}
]);
}
ngOnInit() {
this.dataService.getData().subscribe(=>data {
this.rowData = data
});
}