LyteNyte Grid logo for light mode. Links back to the documentation home page.
Infinite Data Loading

Infinite Rows

Load rows continuously as the user scrolls toward the bottom of the viewport.

Note

Infinite row loading in LyteNyte Grid uses the server data source. You must be familiar with the server data source before reading this guide.

Infinite Row Loading

Infinite row loading detects when the user scrolls near the end of the viewport and requests the next slice of data. When the scroll position reaches a defined threshold, retrieve the current view and request the next slice.

The following example uses the events property on the grid to register a scrollEnd listener. The listener checks whether the scroll position is within 100px of the total scroll height.

<Grid
events={useMemo<Grid.Events<GridSpec>>(() => {
return {
viewport: {
scrollEnd: ({ viewport }) => {
const top = viewport.scrollTop;
const left = viewport.scrollHeight - viewport.clientHeight - top;
if (left < 100) {
const req = ds.requestsForView.get().at(-1)!;
const next = { ...req, start: req.end, end: req.end + 100 };
ds.pushRequests([next]);
}
},
},
};
}, [ds])}
/>

This example shows one approach to implementing infinite row loading. The key implementation detail is creating a request for the next data slice and calling ds.pushRequests to fetch it. For more details, see the Data Interface guide.

The demo below demonstrates infinite data loading using this approach. When you scroll near the end of the grid, the grid loads additional rows after a brief delay.

Infinite Rows

Fork code on stack blitzFork code on code sandbox

Next Steps