DataTable with virtual scrolling

UI Components for React
Post Reply
martinn
Posts: 1
Joined: 15 Mar 2023, 17:13

15 Mar 2023, 17:30

Hi, I've been trying to make the datatable work with virtual scrolling for the past day and a half :D. There is something I cannot wrap my head around:
In the examples ( https://stackblitz.com/edit/react-byvqj ... 2Fdemo.js ) I can see that the initial array ( virtualCars ) has been preset to an empty array with a length of 100000. Now, this works, but if I provide an empty default array, the onLazyLoad function is called with {first:0, last:0}. Is this behavior correct? Shouldn't 'last' be calculated based on the viewport/itemSize? Basically what I am trying to say is, I cannot correctly load the initial data with the following changes from the example above:

* const [virtualCars, setVirtualCars] = useState([]) <-- empty initial array instead of Array.from({10000})

You can check the edited example here https://stackblitz.com/edit/react-ntffl ... %2Fdemo.js and check the console - last is always 0 and not calculated correctly.

Am I missing something?
Any help would be appreciated, thanks!

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests