I am trying to have a basic server side infiniteScroll data table. I set the cacheBlockSize = 20, and maxBlocksInCache = 1. So that it loads 20 records every time from the server, and it only keeps one page of data in the cache. This setup make it easier for me to see how the data loading works. It loads the first page properly at very beginning. But when I scroll down to next 20 records, it should call the API and load new 20 records, then render them on the page. But it keeps calling the API again and again.
I set the grid option like this:
gridOptions: {
headerHeight: 45,
rowHeight: 30,
rowModelType: 'serverSide',
rowSelection: 'multiple',
blockLoadDebounceMillis: 500,
cacheBlockSize: 20,
maxBlocksInCache: 1,
pagination: false,
},
The dataSource is here:
export class MyDatasource implements IServerSideDatasource {
getRows(params: IServerSideGetRowsParams) {
this.searchApi.getData().subscribe(
resp => {
let lastRow = -1;
if (resp['totalRecords'] <= params.request.endRow) {
lastRow = resp['totalRecords'];
}
params.successCallback(resp['data'], lastRow);
},
error => {
params.failCallback();
console.log(error);
},
);
}
}