Skip to content

REST grid adapter

Use the pagination controls to load the next two orders. The example injects a sample REST response through the adapter’s fetch option.

createGridRestAdapter maps a JSON REST service to the existing Pro loader callbacks. The service executes reads and writes and checks permissions. The adapter forwards request cancellation, preserves HTTP error status, and validates the response envelope.

import { createGridRestAdapter, PaginationPlugin } from '@revolist/revogrid-pro';
const rest = createGridRestAdapter<{ id: string; status: string }>({
readUrl: '/api/orders/query',
commandUrl: '/api/orders/commands',
credentials: 'same-origin',
});
grid.pagination = { itemsPerPage: 50, initialPage: 0, loadData: rest.loadPage };
grid.plugins = [PaginationPlugin];

Use rest.loadInfinite as grid.infinityScroll.loadData, or rest.loadGroups as grid.serverSideGrouping.loadRows, when those plugins own the source.

Read modePOST requestSuccessful response
Flatmode: 'flat', offset, limit, sort, and active filter inputs{ data: [{ id: '42', status: 'Open' }], total: 150 }. Infinite scroll may include hasMore.
Groupedmode: 'grouped', group route, level, grouping columns, start, limit, sort, and filter inputs{ groups: [{ key: 'Open', count: 85 }], rowCount: 1 } for a group block, or { rows: [...], rowCount: 85 } for a leaf block. Include authoritative grandTotals when the server calculates them.

Return the total for the filtered dataset in flat mode. For grouped reads, return the number of direct items under the requested route so that the grid can load the remaining blocks. The adapter forwards the canonical filter tree and its execution context when your grid supplies them.

Use rest.batchCommit(toCommand) for the commit callback of BatchEditingPlugin. Your toCommand function maps pending changes to a command envelope with an operationId, a resourceId, the command, and optionally an expectedRevision. Identify records with stable IDs from their models. The position within a loaded page is specific to that view.

To edit a page loaded by PaginationPlugin, enable remotePagination. After acceptance, the grid reloads the authoritative page. The application owns server-side undo and conflict resolution. The following example maps the cell-only editing workflow to an app command. Handle insertions and deletions explicitly if your UI enables them.

import { BatchEditingPlugin, PaginationPlugin } from '@revolist/revogrid-pro';
grid.plugins = [PaginationPlugin, BatchEditingPlugin];
grid.batchEditing = {
remotePagination: true,
commit: rest.batchCommit((transaction) => ({
operationId: transaction.operationId,
resourceId: 'orders',
command: {
updates: transaction.cells.map(({ model, prop, value }) => ({
id: model.id,
field: prop,
value,
})),
},
})),
};

The batch session keeps its operation ID for retries of an unchanged draft.

The service should deduplicate by operation ID and return its original receipt on retry. Keep the operation ID stable when retrying an unknown outcome. An accepted receipt must reflect the submitted values. Use the lower-level rest.submitCommand with command execution for applications that need recovery, conflict details, or custom reconciliation.

{
"operationId": "order-update-923",
"status": "accepted",
"revision": "24",
"changes": { "updatedIds": ["42"] }
}