Troubleshoot server data
Find the cause of missing rows, a wrong page count, lost edits, or a lost selection in a grid that loads rows from your server, and fix it.
Find your symptom below. In a development build, the grid logs a warning for several of these causes. It starts with [data-grid] or the add-on name, such as [data-grid-server]. Read the console first.
Rows are wrong or missing
- A header click selects the column and does not sort. Without
totalRowCount,headerClickBehavioris"select". SetheaderClickBehavior="sort". - The grid sorts or filters the rows again. Without
useDataGridServerRows, the grid sorts and filters itsdata. SetsortMode="server"andfilterMode="server". statusis"error"and the grid shows the last good rows.fetchRowsrejected, threw, or resolved without arowsarray. Fix the cause, then callserver.retry()or select Retry in the error bar.- A page shows fewer rows than
pageSize. The answer repeats a row id, and the hook drops the later copies. Make the sort order unique. - Your route answers 400 with a
ServerSpecErrormessage.parseServerSpecrejected the body, and the message names the part, for examplefilters[2].value. Fix the value that the client sends, or yourcolumnsandlimits. See Check the spec on your server. - A number or date filter matches the wrong rows. Every filter value is text, such as
"5". Convert it on your server for number and date columns. See Operators. - A pushed row stays in its old place. With a server sort or filter, the grid marks a pushed row stale and never moves it. The hook reshapes one second after the push. Call
server.reshape()to reshape at once, or setreshapeDelayMs. See Push into a server-ordered view. - Rows at the end of an answer do not show. The answer holds more than
end - startrows, and the hook uses the firstend - start. Make your server honor the limit. - A slow answer replaces a newer page. With your own fetch, abort the request of a replaced page, as Load rows by page does. The hook does it for you when
fetchRowspassessignaltofetch.
The pager and the count
-
The footer shows "Page 3" in place of a range, and Last stays disabled. The count is unknown. The first answer sent no valid
totalRowCount. Send the count of the filtered result. -
The count stays unknown although the server sends
totalorhasNextPage. The hook readstotalRowCountandhasMoreonly. Rename the fields. Development builds warn. -
The page goes back to page 1. Nothing needs a fix. A change of the page size, the sort, the filter, or the search text gives other pages, so the hook resets the page.
-
The page-size select is missing. With
useDataGridServerPager, passonPageSizeChange.
Edits and saves
- A failed save does not revert the edit. Your
onSavereturns no promise and does not throw. Or the grid isreadOnlyat the refusal and keeps the refused value. Return a promise that rejects or resolves with{ rejected }. See Save edits. - A row stays marked
failed. The mark clears at the next save of the row, or withactions.clearSaveStatus(). - Two users edit the same row, and the later save overwrites the first. Your server accepts every write. Compare
prevwith the stored row and refuse the row. See Handle refused saves. - A new row keeps its client id after the save. Call
actions.replaceRowId(oldId, row)with the server row. See Save edits.
Scroll mode
- Rows show skeletons for a moment after a scroll. A block starts after it stays in the wanted range for
loadDelayMs(default 100). PassloadDelayMs: 0to start at once. - Rows that you scrolled past load again.
maxLoadedRows(default 10,000) unloads the blocks viewed longest ago. Raise it, or passInfinity. See Tune row retention. - The scroll height grows in steps. The source sends no row count, so blocks load one at a time, in order. See Load without row count.
- One block fails while the others load. The grid keeps the loaded rows and shows an error state. Fix the cause, then call
server.retry(). See Recover from load errors.
Selection
Checked rows vanish on a page change, or select all matching does nothing. Both need totalRowCount and checkedRowsLifetime="across-filters", the default with totalRowCount. The hook passes both. With your own fetch, pass totalRowCount to the grid. actions.selectAllMatching() returns the missing one as its reason.
The hook setup
A warning says that the mode changed. The hook cannot switch mode after mount, and React reports a changed hook order. To switch between pages and scroll mode, remount the component with a new key.
Related
- Server rows options: the request, the answer, the checks
- Server rows contract: what your backend returns
- Load rows by page: pages mode
- Save edits:
onSaveand the save status - Recover from load errors: retry a failed block
Show totals from a server
Pin a totals row that your server computes for the whole filtered result, in pages mode, scroll mode, and with your own API.
Load rows by page
Fetch one page of rows per request from your server, show a pager, and keep the page, the sort, the filter, and the row count in step.