Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Pro (paid add-on)

DataGridPro

Pro

DataGridPro is the free DataGrid with the tools data-heavy apps need: columns people can resize, pin, move and hide, filters, grouping with subtotals, tree data, editing in the cell, and copy and paste with spreadsheets.

Part of Pro

This page documents part of @vjdesigns-pro/ui, the paid add-on package. Using it needs a Pro license and @vjdesigns/vjdesigns-ui 3.8.0 or later. Like the free package, it works in both modes, every brand, all 32 languages and right to left. Install it as described in Account forms.

DataGrid or DataGridPro

DataGrid is free. It sorts, searches, selects and pages, works with server-side data, has a full keyboard grid, and stays fast at 100,000 rows. DataGridPro takes every DataGrid prop and adds:

  • Column tools: resizing, pinning, moving, hiding and a column menu, with layouts you can save.
  • Filters per column, shown as chips above the grid.
  • Grouping with subtotals, tree data and master-detail rows.
  • Editing in the cell, with validation.
  • Copy and paste of cell blocks, to and from spreadsheets.
  • Loading while scrolling for server-side data.

Example

Columns add width, minWidth, maxWidth (in px), resizable and pinned, plus the per-column switches menu, hideable, reorderable and pinnable.

tsx
import { DataGridPro } from "@vjdesigns-pro/ui";

<DataGridPro
  aria-label="Season games"
  rows={games}
  columns={[
    { key: "opponent", header: "Opponent", pinned: "start", width: 180, sortable: true, rowHeader: true },
    { key: "points", header: "PTS", headerLabel: "Points", numeric: true, width: 90, sortable: true },
    { key: "notes", header: "Notes", pinned: "end", width: 220 },
  ]}
  columnWidths={savedWidths}
  onColumnWidthsChange={saveWidths}
  selectionMode="multiple"
  pageSize={25}
/>;

Column tools

  • Resizing: drag a header's edge; double-click it to restore the starting width. From the keyboard, focus a header, press F2, then Tab to the resize handle: Arrow Left and Arrow Right change the width by 10 px (50 with Shift), Home and End jump to the limits, Enter restores it and Escape goes back to the grid.
  • Pinning: pinned: "start" or "end" keeps a column at that edge while the grid scrolls sideways. It follows the text direction, so start is the right edge in right-to-left layouts.
  • Column menu: every header gets a menu button to sort, pin, move and hide the column. Columns shows hidden ones again, and Reset columns restores the default layout. From the keyboard, press Alt+Arrow Down on a header. Moves, hides and pins are announced.
  • Moving columns: drag a header to a new place, or use Move left and Move right in the menu. Columns move within their group (start-pinned, unpinned, end-pinned).
  • Saved layouts: widths, order, hidden columns and pinning can each be controlled (columnWidths, columnOrder, hiddenColumns, columnPinning), with a default… prop and an on…Change callback, ready for useLocalStorage or your backend. At least one column always stays visible.

Filters

Every column gets a filter button in its header. Text, number and date columns filter by a condition ("Contains", "Greater than", "Between", "Is empty" and so on); filter: "values" gives a searchable checklist of the column's values with counts. Active filters show as chips above the grid, with "Clear all filters", and the new row count is announced. Filters are plain data; with manual (server-side data) the grid reports them, and applyFilters and matchesFilter let your server apply the same rules.

tsx
<DataGridPro
  columns={[
    { key: "opponent", header: "Opponent" },             // text
    { key: "venue", header: "Venue", filter: "values" }, // choose from values
    { key: "date", header: "Date", filter: "date" },
    { key: "points", header: "PTS", numeric: true },     // number
    { key: "notes", header: "Notes", filter: false },    // no filter
  ]}
  filters={filters}
  onFiltersChange={setFilters}
  …
/>

Grouping, tree data and master-detail

  • Grouping: groupBy={["venue"]} (or "Group by" in a column's menu) adds a header row per value with its row count and the subtotals of columns that set aggregate ("sum", "avg", "min", "max", "count" or a function). Groups nest and collapse.
  • Tree data: getChildren={(row) => row.children} makes rows the top level; rows with children get a toggle. A search or filter keeps the rows above a match.
  • Master-detail: renderDetail={(row) => <Details row={row} />} adds a toggle that opens a full-width panel under the row. Tab moves from the row into its details.
  • Grouped and tree grids are treegrids: each row carries its level and expanded state, and the toggles are buttons with aria-expanded.

Editing

Mark columns editable and handle onCellEdit. Enter, F2, typing or a double-click starts editing; Enter saves, Tab saves and moves to the next editable cell, and Escape cancels. Editors are text, number, date, select or your own. required and validate errors, and errors returned from onCellEdit, keep the editor open, are tied to it with aria-invalid and aria-describedby, and are announced.

tsx
<DataGridPro
  columns={[
    { key: "opponent", header: "Opponent", editable: true, required: true },
    {
      key: "venue",
      header: "Venue",
      editable: true,
      editor: "select",
      options: [{ value: "Home", label: "Home" }, { value: "Away", label: "Away" }],
    },
    {
      key: "points",
      header: "PTS",
      numeric: true,
      editable: true,
      validate: (v) => (v < 0 ? "Can't be negative." : null),
    },
  ]}
  onCellEdit={async (row, key, value) => {
    const error = await save(row.id, key, value);
    if (error) return error; // keeps the cell editing, with this message
    setRows((list) => list.map((r) => (r.id === row.id ? { ...r, [key]: value } : r)));
  }}
  …
/>

Copy and paste

cellSelection lets people select a block of cells (Shift with the arrow keys, a drag, or Shift+click). Copy puts it on the clipboard as tab-separated text that Excel, Numbers and Google Sheets paste as cells. Paste fills editable cells from the focused cell; each value is checked like an edit, values that don't fit are skipped, and the result is announced ("Pasted into 3 cells, 1 cell skipped").

Loading while scrolling

For server-side data, onLoadMore is called when the rows in view come within loadMoreThreshold (20) rows of the end, while hasMore is true and loadingMore is false. Append the new rows to rows; a "Loading more rows…" status shows and is announced meanwhile.

Props

DataGridPro

DataGrid with Pro column tools:

  • resizable columns (drag the header edge, or press F2 on a header, Tab to its handle, and use the arrow keys);
  • pinned columns that stay in view while the grid scrolls sideways;
  • a header menu (its button, or Alt+ArrowDown on the header) to sort, pin, move, and hide a column, and show hidden ones again from "Columns";
  • drag a header to move its column (the menu's "Move left/right" does the same from the keyboard).

Every other DataGrid feature and prop works the same: sorting, filtering, selection, pagination, server-side mode, and the grid keyboard model. Widths, order, hidden columns, and pinning can each be controlled, so a saved layout can be restored. Pinning follows the text direction (start is the right edge in RTL). With multiple selection, the checkbox column is pinned along with any start columns. Columns move within their pin group.

tsx
<DataGridPro
  aria-label="Roster"
  rows={players}
  columns={[
    { key: "name", header: "Player", pinned: "start", width: 200, sortable: true },
    { key: "ppg", header: "PPG", numeric: true, width: 96 },
  ]}
  onColumnWidthsChange={saveLayout}
  onColumnOrderChange={saveOrder}
/>
DataGridPro props
PropTypeDefault
columnsRequired

The columns, with Pro sizing and pinning, in their default order.

readonly DataGridProColumn<T>[]—
resizableColumns

Columns get a resize handle (pointer and keyboard). Per column, resizable wins.

booleantrue
columnWidths

Column widths in px, by key (controlled).

DataGridColumnWidths—
defaultColumnWidths

Initial widths when uncontrolled. Columns not listed use their width.

DataGridColumnWidths—
onColumnWidthsChange

Called with every width while a column is resized. Persist it to remember a layout.

(widths: DataGridColumnWidths) => void—
defaultColumnWidth

Width of columns with no width, in px.

number160
columnMenu

Each header gets a menu button (also opened with Alt+ArrowDown on the header) to sort, pin, move, and hide the column, with a "Columns" list to show hidden columns again. Per column, menu wins.

booleantrue
reorderableColumns

Columns can be moved by dragging their header, or from their menu. Per column, reorderable wins.

booleantrue
columnOrder

Column keys in display order (controlled). Unknown keys are ignored; columns not listed follow in definition order.

string[]—
defaultColumnOrder

Initial order when uncontrolled.

string[]—
onColumnOrderChange

Called with every column key, in the new order, after a column moves.

(order: string[]) => void—
hiddenColumns

Keys of hidden columns (controlled). At least one column always stays visible.

string[]—
defaultHiddenColumns

Initially hidden columns when uncontrolled.

string[]—
onHiddenColumnsChange

Called with the hidden keys after a column is hidden or shown.

(hidden: string[]) => void—
columnPinning

Pin sides by key (controlled). Overrides each column's pinned.

DataGridColumnPinning—
defaultColumnPinning

Initial pinning when uncontrolled.

DataGridColumnPinning—
onColumnPinningChange

Called after a column is pinned or unpinned from its menu.

(pinning: DataGridColumnPinning) => void—
columnFilters

Each header gets a filter button (also "Filter" in its menu). Active filters show as chips above the grid. Per column, filter wins.

booleantrue
filters

Column filters by key (controlled). With manual, the grid reports them and shows rows as given.

DataGridFilters—
defaultFilters

Initial filters when uncontrolled.

DataGridFilters—
onFiltersChange

Called with every active filter after one is applied, changed, or removed.

(filters: DataGridFilters) => void—
groupBy

Column keys to group rows by, outermost first (controlled). Each group gets a header row with its value, row count, and column subtotals, and collapses. Grouped grids show every row (no pages); sorting applies inside each group.

string[]—
defaultGroupBy

Initial grouping when uncontrolled.

string[]—
onGroupByChange

Called when the user groups or ungroups by a column.

(groupBy: string[]) => void—
getChildren

Tree data: each row's child rows. rows are the top-level rows. Rows with children get a toggle; a row stays when it or any row under it passes the filters. Ignores groupBy.

(row: T) => readonly T[] | undefined—
expandedRows

Ids of expanded tree rows (controlled).

string[]—
defaultExpandedRows

Initially expanded tree rows when uncontrolled.

string[][]
onExpandedRowsChange

Called when a tree row is expanded or collapsed.

(expanded: string[]) => void—
renderDetail

Master-detail: content shown in a full-width row under a row, opened from a toggle in its first cell. Tab moves from the row into its details. A grid with details doesn't virtualize; pair it with pageSize.

(row: T) => ReactNode—
expandedDetails

Ids of rows with their details open (controlled).

string[]—
defaultExpandedDetails

Initially open details when uncontrolled.

string[][]
onExpandedDetailsChange

Called when a row's details open or close.

(expanded: string[]) => void—
onCellEdit

Turns on inline editing for editable columns. Called with the row, the column key, and the new value once it passes validation; update rows. Return (or resolve to) an error message to keep the cell in editing with that error, for example when the server rejects the change.

(row: T, key: string, value: unknown) => void | string | null | undefined | Promise<void | string | null | undefined>—
cellSelection

Cell ranges: Shift with the arrow keys, a drag, or Shift+click selects a block of cells. Copy puts it on the clipboard as tab-separated text (what spreadsheets use); paste fills editable cells from the focused cell (or repeats one value across the range), with each value checked like an edit.

booleanfalse
onCellsPaste

Saves a paste in one go: every valid change, in order. Without it, each change goes through onCellEdit.

(changes: { row: T; key: string; value: unknown; }[]) => void | Promise<void>—
onLoadMore

Loading while scrolling (server-side data): called when the rows in view come within loadMoreThreshold rows of the end, while hasMore is true and loadingMore is false. Append the new rows to rows. The grid then shows every loaded row in one virtualized list (no pageSize).

() => void—
hasMore

More rows can be loaded.

booleanfalse
loadingMore

Rows are loading: shows (and announces) a status under the grid.

booleanfalse
loadMoreThreshold

How close to the end, in rows, onLoadMore is called.

number20

DataGridProColumn

A DataGrid column with Pro sizing, pinning, and column management. Widths are in px.

DataGridProColumn props
PropTypeDefault
width

Starting width in px. Falls back to the grid's defaultColumnWidth.

number—
minWidth

Narrowest the user can make it, in px.

number64
maxWidth

Widest the user can make it, in px.

number800
resizable

Let the user resize this column.

booleanthe grid's `resizableColumns`
pinned

Keep the column in view while scrolling sideways. Pinned columns move to that edge, in their order. The grid's columnPinning wins.

"start""end"—
menu

Show this column's header menu.

booleanthe grid's `columnMenu`
hideable

Let the user hide this column (from its menu or the "Columns" list).

booleantrue
reorderable

Let the user move this column (drag its header, or "Move left/right" in its menu).

booleanthe grid's `reorderableColumns`
pinnable

Let the user pin and unpin this column from its menu.

booleantrue
filter

How this column is filtered: text, number, date, or values (a checklist of the column's values). false turns its filter off.

false"number""text""values""date""number" for numeric columns, otherwise "text" (when the grid has `columnFilters`)
groupable

Let the user group rows by this column (from its menu).

booleantrue
aggregate

The subtotal this column shows in each group row: sum, avg, min, max, count, or a function of the group's rows.

DataGridAggregate<T>—
editable

Cells of this column can be edited (with the grid's onCellEdit). A function decides per row.

boolean | ((row: T) => boolean)—
editor

How the cell is edited: text, number, date ("YYYY-MM-DD"), select (with options), or your own editor.

DataGridEditorType | ((props: DataGridEditorProps<T>) => ReactNode)"number" for numeric columns, otherwise "text"
options

Choices for a select editor.

readonly { value: string; label: string; }[]—
required

An edit can't leave this cell empty.

boolean—
validate

Checks an edit before it's saved: return an error message to show, or nothing when it's valid.

(value: unknown, row: T) => string | null | undefined—

DataGridColumnFilter

One column's filter.

DataGridColumnFilter props
PropTypeDefault
operator

The condition (text, number, and date filters).

"contains""equals""notEquals""startsWith""greaterThan""lessThan""between""before""after""isEmpty""isNotEmpty"—
value

The value to compare with. Dates are "YYYY-MM-DD".

string | number—
value2

The upper bound, for between.

string | number—
values

The chosen values, for a values filter ("" stands for empty cells).

readonly string[]—

FilterableColumn

A column as filtering sees it: its key, how it's filtered, and how its value is read.

FilterableColumn props
PropTypeDefault
keyRequiredstring—
typeRequired"text""number""date""values"—
valueRequired(row: T) => unknown—