Read a push verdict
Read how many cells a push wrote, which patches the grid skipped and why, and when an async schema settles the batch.
updateCells and updateRows check every patch. The verdict tells you what the grid wrote and what it skipped. See Push live values for the call.
updateCells and updateRows return an UpdateCellsVerdict:
appliedcounts the cells the call wrote.skippedholds oneUpdateCellsSkipper patch that the grid checked and did not write, with itspatchIndexand areason. Two patches to one cell in one batch count once, and the last one wins.pendingistruewhile an async schema holds the batch.settledresolves with the final verdict. A superseded batch resolves withapplied: 0and noskippedentries.
| Reason | Meaning |
|---|---|
unknown-row | The row id is not in data. |
unknown-column | The column id is not a known column. |
hole | The id is the placeholder id of an unloaded scroll-mode row. A push by the real id of a row that is not loaded gets unknown-row. |
readonly | A call with no source on a readOnly grid gets it. A call with another source gets it when the grid is readOnly, the column is read-only, or the row is read-only through readOnly(row). A "stream" call gets this reason for a column with no write path (accessorFn without setValue). |
saving | A stream call: the row has a save in flight. The grid holds the patch and applies it once the row's save settles. A later push to the same cell replaces it. |
limit | A stream call: the call carried more than 100,000 patches, and this patch came after them. |
no-source | The call passed no source. The grid writes nothing. Pass { source: "stream" } or { source: "edit" }. |
invalid | The column's validate rejected the value. |
no-op | The value equals the current value. |
Read the verdict
settled is set only while pending is true. This hook pushes patches, waits for an async schema, and returns the number of cells the call wrote:
"use client";
import { useCallback } from "react";
import {
useDataGridActions,
type CellPatch,
} from "@/components/data-grid/data-grid";
export function usePush() {
const actions = useDataGridActions();
return useCallback(
async (patches: CellPatch[]) => {
const verdict = actions.updateCells(patches, { source: "stream" });
const final = (await verdict.settled) ?? verdict;
for (const skip of final.skipped) {
console.warn(`Patch ${skip.patchIndex} skipped: ${skip.reason}`);
}
return final.applied;
},
[actions],
);
}Related
- Push live values: write patches, and flash changed cells
- Push into a server-ordered view: stale rows
- Validation: the
validatethat rejects a value - Data change events: the operations that a push reports
Push into a server-ordered view
Mark pushed rows as stale, reshape the view from the server, and delete rows that the server removed, when the server sorts or filters the rows.
Show presence
Paint the selections of remote users into the grid with the data-grid-presence add-on, without a re-render of any row or cell.