SpreadsheetGrid
API reference

serverSide mode (SSRM)

dataSource / query wiring / refresh / error handling / write-back

One reference for both the React and Solid versions

Props, column definitions, handle methods, callbacks, and CSS classes and tokens are the same in both. The example code is written for React. Pick Solid at the top of the sidebar to see how to read it for the Solid version here.

serverSide mode (SSRM)

Passing dataSource switches to serverSide mode: it keeps a vertical scroll space for the total number of rows and fetches only the blocks near the visible window with getRows (the fetched range is bounded by constants, so memory stays bounded). Unloaded rows are drawn as skeleton rows and replaced with real data when it arrives. rows (clientSide) and dataSource (serverSide) are mutually exclusive. Cell editing is enabled only when dataSource.updateRows is given (write-back with optimistic updates; see "Writing cell edits back (updateRows, optimistic updates)").

Wiring the query

The clientSide interaction state (global filter, column filters, sort) is assembled into a ServerSideQuery and sent as getRows's params.query (running filters / sort is left to the server).

  • ServerSideQuery: { globalText?: string; columnFilters?: Record<string, ColumnFilterValue>; sort?: GridSortState }. When every field is empty, {} is passed.
  • Wire format of column filters: ColumnFilterValue is a discriminated union with kind, sent as is (the server interprets the descriptor and builds the WHERE). Shapes by kind:
    • { kind: 'set'; mode?: 'include' | 'exclude'; values: string[] } — mode changes what values means ('include' = the chosen values / 'exclude' = the unchecked values; omitted is 'include'). Which one you get isn't decided by the number of options: when you start unchecking from select-all, columns without filterOptions become 'exclude' (the unchecked values) and columns with filterOptions become 'include' (the remaining values), and later checking and unchecking keeps the mode. Searching and pressing Enter gives 'include' (the values matching the search), and selecting nothing gives 'include' with an empty array. Blank cells are ''. The server builds IN / NOT IN according to mode (treating NULL and empty strings as '').
    • { kind: 'number'; raw: string; parsed } — parsed is { mode: 'comparison'; operator: '>' | '>=' | '<' | '<=' | '=' | '!='; value: number } / { mode: 'range'; min: number; max: number } (both ends inclusive) / { mode: 'blank' } / { mode: 'notBlank' } / null (= partial match on raw; a compatibility value from the old UI). parsed is always authoritative, and raw is a human-readable display string (built from the grid's text localeText; conditions put in by the AI bar (/ai) are built from the bar's localeText. By default Japanese like 「10 以上」 (10 or more), and English like "≥ 10" with localeTextEn (since 1.0.2; through 1.0.1 it was Japanese regardless of language). Old values are expression strings like ">=10"). Use parsed for the server's check, not raw. For comparison / range, blank cells (null / undefined / empty string) don't match (use blank / notBlank to pick blanks).
    • { kind: 'numberSet'; condition; set } — a combination of condition AND selection (filterType: 'numberSet'). condition has the same shape as parsed above (null = no condition), and set is { mode?: 'include' | 'exclude'; values: string[] } (null = all selected). The server builds the WHERE as condition AND set (e.g. qty >= 10 AND qty NOT IN (12)). A value with both null isn't sent (normalized to clear on the client).
    • { kind: 'textSet'; condition; set } — the text version of the combination (filterType: 'textSet'). condition is { mode: 'contains' | 'equals' | 'startsWith' | 'endsWith'; value } / { mode: 'blank' | 'notBlank' } / null (matching ignores case; value is trimmed). The rule of AND with set is the same as numberSet.
    • { kind: 'dateSet'; condition; set } — the date version of the combination (filterType: 'dateSet'). condition is { mode: 'range'; from; to } / { mode: 'onOrAfter' | 'onOrBefore' | 'equals' | 'notEquals'; value } / { mode: 'blank' | 'notBlank' } / { mode: 'preset'; preset: string } (built-ins are 'today' / 'thisMonth' / 'last30days'; custom IDs defined in the column's dateFilterPresets are sent as they are too) / null. Dates are 'YYYY-MM-DD' (zero-padded ISO). Relative presets are sent as relative, so the server should resolve them against "today" at the time it receives them (the client's clientSide evaluation follows the same rule). When "today" is depends on the time zone, and resolving on the server gives today in the server's time zone (for a user in Tokyo, 0–9 AM is still the previous day on a UTC server). To filter by the user's today, getRows is called in the browser, so add the user's time zone (Intl.DateTimeFormat().resolvedOptions().timeZone) or today's date to the request there and send it to the server, and the server decides the range from that date (the guide "Server-side row model", section "Relative dates and time zones"). If the date changes while the grid is open, blocks are refetched on days when the relative preset's range changes (every day for "today", at the start of the month for "this month") (the content of the query sent is the same; the cache is told apart by an internal key. Preset IDs not in the column definitions are refetched every day because their range is unknown). Interpreting custom IDs (id → WHERE clause) is also the server's job (resolve is for client evaluation only and isn't sent). set.values are normalized date keys, not raw cell values ('YYYY-MM-DD'; blank = '' / values that can't be read as a date = the raw value).
    • { kind: 'text'; value } / { kind: 'date'; value } — both are a partial match on value (trimmed) (ignoring case). filterType: 'date' is also a partial text match, not a date range: for example { kind: 'date', value: '2025-01' } matches rows whose cell value string (the return value of getValue, before valueFormatter) contains "2025-01" (to filter by a date range, use filterType: 'dateSet').
    • { kind: 'select'; value } — an exact match between the cell value's string and value.
    • { kind: 'custom'; value } — a free-form value for columns using column.filterFn (interpreting it on the server is the consumer's job).
    • Only active filters are sent. Keys are sorted ascending for a stable queryKey.
  • debounce: query (filter / sort) changes are sent once after about 300ms of quiet (merging refetches per keystroke). The input boxes themselves update right away.
  • scroll-reset: when the query changes, the result set is replaced entirely, so the scroll goes back to the top.
  • enable* flags: enableSorting / enableColumnFilter / enableGlobalFilter (all default true) work in serverSide too. Set them to false to block operations the server doesn't support.

Options for set / select filters (SSRM)

The option sets for set / select / combined (numberSet / textSet / dateSet) filters must be supplied by the client. clientSide can collect them automatically from all rows, but serverSide can't, because the client doesn't hold every row, so the options are empty (the condition box of combined filters doesn't depend on options, so it always works in serverSide too).

  • Low-cardinality columns (status, category and so on): give filterOptions statically in the column definition (works as set in serverSide too).
  • Blank cells: if the options (filterOptions / the return value of getFilterOptions) have no '', the 「(空白)」 (blank) item doesn't appear, and 'include' selections (unchecking values in columns with filterOptions / searching and pressing Enter and so on) don't include blanks, so blank rows disappear too. To be able to keep blank rows, put { value: '', label: '(Blank)' } in the options (the server reads '' as NULL / empty string).
  • High-cardinality columns (part numbers, IDs and so on): set isn't suitable to begin with. Use filterType: 'text' (partial match) or a number range.
  • Supplied asynchronously from the server: with the grid prop getFilterOptions (async-options), it is called with { columnKey, column, columnFilters (other columns), globalText, signal } every time the popover opens, and the returned { options, truncated? } becomes the options (with loading / failure + retry / truncation note displays; invertible). Even high-cardinality columns can use a set filter with a bounded DISTINCT + truncated: true.
  • Opening a set / select column with neither filterOptions nor getFilterOptions in serverSide shows in the option list that "no options were given" (not a bug but missing configuration).

dataSource and parameters

  • initialRowCount: pass it to show the correct total height / scrollbar before the first fetch (without it, the count is 0 until the first getRows result returns). Read only once at mount (see the remount contract below).
  • blockSize (default 100) / maxCachedBlocks (default 64): the number of rows per block and the client-side LRU limit. Beyond it, old off-screen blocks are evicted.
  • The getRows(params) contract: params is { startIndex, endIndex, query, signal }. Respect the given [startIndex, endIndex) (view space, end exclusive) and don't return everything. Return the total count after filtering with query applied in result.totalRowCount (the vertical scroll space follows it). When signal is aborted, reject promptly.
  • result: { rows: T[]; totalRowCount: number }. rows is the rows that exist in the requested range (may be shorter than requested at the end).
  • updateRows(params) (optional): the entry point for writing cell edits back. Giving it enables cell editing in serverSide too (without it, the editing UI is off altogether). See "Writing cell edits back (updateRows, optimistic updates)".

Refetching the latest from the server (refreshServerSide() / serverSideRefreshToken)

When you want to refetch the server's latest without changing the query, such as when data on the server was updated elsewhere, call refreshServerSide() on the imperative handle. To handle it declaratively (a design that carries "should refresh" as a signal in state management), incrementing serverSideRefreshToken (number) behaves the same (both delegate to the same internal soft refresh).

  • Difference from a queryKey change: a filter / sort / global filter change replaces the whole result set, so it resets the scroll to the top, drops the whole cache and refetches from block 0. A soft refresh drops the cache while keeping the scroll position and refetches the current visible range right away (no debounce).
  • Count: on refresh the count isn't reset; it is updated with the totalRowCount of arriving blocks. If an outside update changed the count, the vertical scroll space follows. Refreshing before the visible range is established or from a count of 0 (empty result) refetches block 0 as a bootstrap (so a table that became empty can recover after the server gets data).
  • Behavior notes: during the refetch, the target rows briefly show as skeletons (purge → refetch). To refetch while keeping the previous rows shown, use serverSideRefetch="keep" (see "What shows during a refetch" below). Use refreshToken as monotonically increasing (it refetches only when the value changes). It doesn't fire on first mount.
  • Use: intended as the trigger to reflect mutations (edits / additions / deletions) made elsewhere. Cell edits on the grid can be written back directly with dataSource.updateRows (see "Writing cell edits back" below), so this isn't needed for them. Adding and removing rows has no write-back API, so use the "apply on the server → refreshServerSide()" flow (AG Grid effectively works this way too).

What shows during a refetch (serverSideRefetch)

When conditions (sort / column filters / global filter) change and on refetches (refreshServerSide() / serverSideRefreshToken), by default ('skeleton') rows become loading rows (skeletons). With serverSideRefetch="keep", the previous rows stay shown, dimmed, until the new rows arrive (since 1.5.0).

<SpreadsheetGrid dataSource={dataSource} columns={columns} rowKeyGetter={(row) => row.id} serverSideRefetch="keep" />
  • Look: the previous rows appear at the strength of --ssg-refetch-row-opacity (default 0.45) (dimmed by laying a surface of the cell background color over the visible part of the body. The row elements' opacity isn't changed, so center columns don't show through under pinned columns), and a line flowing left to right appears under the column headers (.ssg-refetch-bar; color --ssg-refetch-bar, track --ssg-refetch-bar-track). The root gets .ssg-root--refetching and the table (role="grid") gets aria-busy="true". When motion is 'off', the line doesn't move (a full-width still line).
  • When it swaps: once all the blocks of the visible range (the rows being drawn) have arrived with the new conditions, it swaps them in at once (the count becomes the new totalRowCount too). It doesn't mix blocks in as they arrive (so it never shows a table with the new order on top and the old order below). When fetching a block in the visible range fails, it stops showing the previous rows and shows the failure (loading rows + the error bar). It doesn't wait for blocks outside the range.
  • Scrolling: when conditions change, it goes back to the top as up to 1.4 (showing the top of the previous rows dimmed). Refetches keep the scroll position. If you scroll while the previous rows are shown, to a place outside the previous rows' loaded blocks, those become loading rows.
  • Editing: while the previous rows are shown, starting edits, pasting, deleting and the fill handle don't happen (the positions of the previous rows don't match the new result. When a refetch starts during an edit, committing that edit doesn't write). The cells' read-only mark, aria-readonly and renderCell's readOnly don't change. Writes being saved before the previous rows start showing are settled before refetching (as up to 1.4). That value keeps showing in the previous rows until it is saved.
  • When there are no previous rows: on the first fetch, and when no block has arrived yet, it shows loading rows even with 'keep'. When conditions change again while the previous rows are shown, it keeps showing the first previous rows and refetches with the new conditions (rows that arrived partway are dropped).

Errors and retry when getRows fails

When getRows rejects (other than abort; the same when it throws synchronously before returning a Promise), the failed block's rows stay as skeletons and an error bar appears at the bottom center of the grid (「行の取得に失敗しました(N ブロック)」 (Failed to load rows (N blocks)) + 「再試行」 (Retry) / 「閉じる」 (Close)).

  • Retry: refetches only the failed blocks right away (no debounce). Cached blocks aren't touched (no full purge like refreshServerSide()). If it fails again, the bar shows again.
  • No re-request on scroll: failed blocks aren't refetched automatically when you scroll back to them (to avoid re-requesting on every scroll and firing onServerSideLoadError repeatedly while the server is down; the same approach as AG Grid's retryServerSideLoads()). They are refetched only by the retry button / the handle's retryServerSideLoads() / refreshServerSide() / a query change.
  • Close (×): hides it only while the failure state stays the same. A new failure (a change in the set of failures) shows it again. A query change / refreshServerSide() / full recovery resets the failure state.
  • Aborts: cancellations by scrolling past, query changes and unmount (signal abort) aren't treated as failures (no bar, no notification).
  • Outside notification: independent of the bar, onServerSideLoadError(error, { startIndex, endIndex }) is called for each failure (for toasts / logs).

Writing cell edits back (updateRows, optimistic updates)

Giving dataSource.updateRows enables cell editing in serverSide too (editor commits / paste / Delete clear / renderCell's setValue / checkbox toggles), and edits are written back to the server through this entry point. Without it, the serverSide editing UI is off altogether (cells show as readOnly and editors don't open, so edits with nowhere to write back aren't accepted).

const dataSource: ServerSideDataSource<Row> = {
  getRows: async ({ startIndex, endIndex, query, signal }) => { /* fetch */ },
  updateRows: async ({ updates }) => {
    // updates: per-row update descriptors (1 user action = 1 call; multiple rows of a paste are merged into 1 too)
    //   { rowKey, rowIndex, row, previousRow, changes: [{ columnKey, previousValue, newValue }] }
    await api.patchRows(updates);
    // no return value (or {}) = commit the grid's optimistic values as they are.
    // if the server normalized / computed values, return the committed rows in the same order and length as updates to merge them into the cache:
    // return { rows: updates.map((u) => normalize(u.row)) };
  },
};
  • Optimistic updates: edits first show on screen right away (optimistic values) and are committed when updateRows resolves. Even if blocks are refetched or evicted by the LRU before commit, the optimistic values stay shown (uncommitted edits are held in a layer separate from the cache).
  • Rollback on failure: when updateRows rejects (the same when it throws synchronously before returning a Promise), the cells automatically go back to their values before the edit, and a save failure bar appears at the bottom of the grid (「変更の保存に失敗しました(N 行)。値を元に戻しました」 (Failed to save changes (N rows). The values were put back) + Close) (it goes away when closed or at the next refetch = refreshServerSide() / a filter / sort change). The values are already restored, so there is no retry button (if you need a way to retry, resend yourself from params.updates of onServerSideWriteError).
  • onServerSideWriteError(error, { updates }): an outside notification independent of the bar (for toasts / logs / a way to retry). updates is the row updates that failed and were put back, and changes is only the cells put back. Changes to cells that a newer write had changed (already overwritten) have nothing to put back, so they aren't included, and if all were overwritten, neither the bar nor the notification appears (to prevent resending that would overwrite new values with old ones). For the same reason, row is the current displayed row (including new edits to the same row) with the reverted changes applied (previousRow stays the row before that write).
  • Consecutive edits to the same row: you may edit the same row again before the previous write is committed (the new edit governs the display, and a late settlement of the old write never rolls back the new value). A commit applies only to the cells that write changed, and if a newer write already committed the same cell, the old write doesn't write that cell. When an old write fails, only the cells that write changed are put back (values of newer writes being saved stay). The rollback target on failure is "the value last committed by the server" (if an older write that changed the same cell is still being saved, that write's value).
  • Relation to validation: validate / validationMode work with the same rules as clientSide (reject columns refuse commits and skip cells in paste / clear; mark columns write back invalid values too and show marks).
  • Copy range: Ctrl/Cmd+C copies only loaded rows (unloaded rows are skipped, not even turned into empty rows). Even selecting everything with Ctrl/Cmd+A copies only loaded rows (when you need every row, get it from the server, as with export).
  • Paste / Delete clear range: unloaded rows (skeletons) are skipped. Paste doesn't expand rows / columns automatically (createRow / createOverflowColumn don't fire in serverSide; add rows with the "apply on the server → refreshServerSide()" flow).
  • undo/redo: stays off in serverSide (there are no full rows to apply to; handle undo with history on the server).
  • Relation to refreshServerSide() / query changes: refreshing or changing filter / sort while writes are being saved (in flight) removes the optimistic values (rows become skeletons) and refetches the server's source of truth after the save settles (waiting at most 3 seconds. After that it refetches without waiting, and if the save then succeeds, the refetched rows may be old values from before the server applied it, so it refetches the visible range once more while keeping the rows shown. If it then fails, only the notification is given). Saves aren't dropped, so even usage like "add a row and refreshServerSide()" doesn't show the last edit with an old value. Save failures that settle while waiting are also reported by the save failure bar / onServerSideWriteError (rows are skeletons while waiting, so the ✓ / ✕ marks on cells don't appear. The positions of refetched rows can change, so the settled rows aren't written to the cache). Only on unmount is the settlement not reported.
  • Identifiers: rowKey comes from rowKeyGetter (the default is the view index, so when using write-back, giving a rowKeyGetter that returns stable keys is recommended). rowIndex is the row position in view space (after the current filter / sort), and previousRow holds the snapshot before the edit so the server can identify the row.

Switching between clientSide and serverSide (remount contract)

initialRowCount and the internal row count state are fixed at mount. So when switching modes at runtime, change key to remount the grid (adding dataSource later after mounting in clientSide doesn't initialize the count). This doesn't apply to normal use that mounts directly in serverSide.

On this page