Request only needed blocks
Fetch the blocks needed at the current scroll position through datasource.
Provide an API accepting start and end rows and returning that order range. This page's table uses local samples and does not request additional server rows.
View code
Sample data included in the code · 6 rows
Usage guide
#For hundreds of thousands of orders, fetch only scrolled ranges from the server instead of downloading every row at once.
Integration steps
- Prepare a query API
Provide an API accepting start and end rows and returning that order range. This page's table uses local samples and does not request additional server rows.
- Connect requests
In datasource.getRows, pass params.startRow and params.endRow to the server. Include sorting and search conditions when applicable.
- Report success or failure
Call params.success with response rows and the total count. On failure, call params.fail so loading ends.
Scrolling in your app requests needed ranges and populates them with actual rows when responses arrive.
Call either success or failure only once per getRows request. /api/orders below is an example connection endpoint.
Useful terms
- datasource
- An object connecting Grid data requests to a server API.
- Block
- A group of rows fetched in one request.
Key API examples
Application code that references the registered Grid element as grid.
grid.datasource = {getRows: async params => {
try {
const response = await fetch('/api/orders', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({startRow:params.startRow,endRow:params.endRow,sortModel:params.sortModel,filterModel:params.filterModel,quickFilter:params.quickFilter})});
if (!response.ok) throw new Error('Query failed');
const {rows,total} = await response.json();
params.success(rows,total);
} catch { params.fail(); }
}};API reference
#Other properties3
| Attribute / Property | Type / Default | Description |
|---|---|---|
InfiniteRowDatasourceDefault: undefined | infinite (lazy) row model datasource. When set, the grid ignores `rowData` and fetches rows in blocks from this datasource as the user scrolls (ag-grid `infiniteRowModel`). Unloaded rows render as loading placeholders until their block resolves. | |
| cacheBlockSize | numberDefault: 100 | rows per fetch block for the infinite row model. |
| maxBlocksInCache | numberDefault: undefined | max loaded blocks kept in memory (LRU); omit for unbounded. |
Methods1
| Method / Arguments | Return type | Description |
|---|---|---|
Promise<void> | purge the cache (e.g. sort/filter changed) and refetch. |
Explore each feature
Learn when to use each feature and how to configure it. Each guide identifies live examples and features you connect in your app.