WarUI documentation

Infinite scroll blocks with unknown total

experimental

Load fixed-size blocks from a feed with no total and detect the end of data.

Live example

Expected behavior

The scroll area covers loaded rows plus a growth zone. Scrolling near the bottom loads the next block. When a short block or an explicit last-block flag arrives, the row count becomes exact, the growth zone is removed and endOfDataReached fires once.

Source

const api = createGrid({
  rows: [],
  columns,
  rowModel: 'remote',
  blockSize: 100,
  infiniteGrowthRows: 100,
  remoteSource: {
    async fetchWindow({ startIndex, endIndex, cursor, signal }) {
      const res = await fetch(`/feed?limit=${endIndex - startIndex}&cursor=${cursor ?? ''}`, { signal });
      const { rows, next, last } = await res.json();
      return { rows, nextCursor: next, isLastBlock: last };
    },
  },
});
api.on('endOfDataReached', ({ totalCount }) => announce('All rows loaded'));

API reference

GRID-A04-F04 API
KindNameTypeDescription
OptionblockSize—Aligns every request to blocks of this size.
OptioninfiniteGrowthRows—Rows added to the scroll area while the total is unknown.
PropertyWindowResult.isLastBlock—Marks the final block.
PropertyWindowRequest.cursor—The previous block's nextCursor.
EventendOfDataReached—Fires once when the end of data is known.