3
votes

@swimlane/ngx-datatable virtual scroll works only with cached rows. Cached rows keep in the array. In my case, the number of that rows can be more than 10 million. How to not cache that rows and use the virtual scroll?

Reproduction of the problem:

1) Example of current behavior virtual scroll without cached rows: http://prntscr.com/kw9q51

2) Repo: https://github.com/DmitriyIvanko/ngx-datatable-example/blob/master/src/app/app.component.ts

1

1 Answers

0
votes

My hack solution is simulate cached rows: For example user request take: 20 rows, skip: 50 rows, total rows: 100; Create array of 'undefined' (with length 100), and replace 20 rows starts from 50-th row;

const totalRow = 100;
const skip = 50;
const take = 20;
const serverRow = [{...}] // array of row, with length = 20;

const resultList = new Array(totalRow).fill(undefined);
resultList.splice(skip, serverRow.length, ...serverRow);

I check this solution with 10 million rows and it is works really fast; Maybe this will help someone.