Data Grid

PreviousNext

A spreadsheet-like data grid with inline editing, cell selection, copy-paste, and dynamic column generation

Spreadsheet-like data grid built on react-data-grid with inline editing, copy-paste, keyboard navigation, and dynamic column generation.

Basic Usage

The simplest form displays an editable grid with text and number columns.

Name
Email
Amara Diallo
amara@example.com
Jane Smith
jane@example.com
Bongani Dube
bongani@example.com
Alice Williams
alice@example.com

Dynamic Columns

Generate columns dynamically from external data source definitions. This is useful when column structure comes from an API or configuration.

Programme
Fee (R)
Exodus Recovery Skills
1,500
Vantage
1,500
Resound
1,200
Small Group Facilitation
2,500

Row Selection & Batch Operations

Enable row selection with checkboxes and batch operations like delete and copy.

#
Name
1
Amara Diallo
2
Jane Smith
3
Bongani Dube
4
Alice Williams

Custom Cell Editors

Use different editor types for different data types: text, number, date, and dropdown select.

Programme
Fee (R)
Exodus Recovery Skills
1,500
Vantage
1,500
Resound
1,200
Small Group Facilitation
2,500

All features enabled: search, add/delete rows, row selection, sorting, and custom toolbar actions.

#
Programme
1
Exodus Recovery Skills
2
Vantage
3
Resound
4
Small Group Facilitation

Variants

Striped Variant (Compact)

Alternating row backgrounds with compact spacing for dense data.

#
Name
1
Amara Diallo
2
Jane Smith
3
Bongani Dube
4
Alice Williams

Minimal Variant

Clean design with top border only.

Name
Email
Amara Diallo
amara@example.com
Jane Smith
jane@example.com
Bongani Dube
bongani@example.com
Alice Williams
alice@example.com

Column Helper Functions

The component provides helper functions to create commonly used column types:

// Row numbering column (frozen, non-editable)
createRowNumberColumn<TData>(): Column<TData>
 
// Selection checkbox column
createSelectColumn<TData>(): Column<TData>
 
// Editable text input
createEditableTextColumn<TData>(key: string, name: string, width?: number): Column<TData>
 
// Editable number input
createEditableNumberColumn<TData>(key: string, name: string, width?: number): Column<TData>
 
// Editable date picker
createEditableDateColumn<TData>(key: string, name: string, width?: number): Column<TData>
 
// Editable dropdown select
createEditableSelectColumn<TData>(
  key: string,
  name: string,
  options: string[],
  width?: number
): Column<TData>
 
// Read-only text column
createTextColumn<TData>(key: string, name: string, width?: number): Column<TData>
 
// Generate columns from external definitions
createDynamicColumns<TData>(definitions: ColumnDefinition[]): Column<TData>[]

Keyboard Shortcuts

The Data Grid includes built-in keyboard navigation for a spreadsheet-like experience:

ShortcutAction
Arrow KeysNavigate between cells
TabMove to next cell
Shift+TabMove to previous cell
EnterEdit selected cell
EscapeCancel editing
Ctrl+C (or Cmd+C)Copy selected cells (TSV format)
Ctrl+V (or Cmd+V)Paste clipboard data
DeleteClear selected cell content
Shift+ArrowExtend selection range

Copy-Paste Functionality

The Data Grid supports Excel-compatible copy-paste:

  1. Cell-level: Select cells and press Ctrl+C to copy in TSV format
  2. Row-level: Use toolbar "Copy Selected Rows" button
  3. All data: Use toolbar "Copy All Data" button

Copied data can be pasted directly into Excel, Google Sheets, or any application that accepts TSV format.

Props API

PropTypeDefaultDescription
dataTData[]-Array of data objects to display
columnsColumn<TData>[]-Column definitions (use helper functions)
columnDefinitionsColumnDefinition[]-Optional: Generate columns dynamically
onDataChange(data: TData[]) => void-Callback when data changes (edit/add/delete)
variant"default" | "minimal" | "striped""default"Visual style variant
size"default" | "compact""default"Size variant
enableRowSelectionbooleanfalseEnable checkbox row selection
enableAddRowbooleanfalseShow "Add Entry" button in toolbar
enableDeleteRowbooleanfalseShow "Delete" button when rows selected
enableSearchbooleanfalseShow search input in toolbar
enableSortingbooleanfalseEnable column sorting
searchPlaceholderstring"Search..."Placeholder text for search input
onAddRow() => TData-Function that returns a new empty row object
toolbarActionsReactNode-Custom action buttons in toolbar
showToolbarbooleantrueShow/hide toolbar
emptyMessagestring"No data available"Message when no data
rowHeightnumber35Height of each row in pixels
classNamestring-Additional CSS classes for grid
classNamesobject-CSS classes for wrapper, toolbar, grid

ColumnDefinition Type

When using dynamic columns via columnDefinitions:

interface ColumnDefinition {
  key: string;               // Data property key
  name: string;              // Column header label
  type: "text" | "number" | "date" | "select";  // Editor type
  editable?: boolean;        // Whether column is editable (default: true)
  options?: string[];        // Options for "select" type
  width?: number;            // Column width in pixels
}