Editing - overview

Inline editing is a single prop on <SvGrid>. Try it - double-click any cell, type to replace, hit Enter to commit. Tab moves to the next editable cell:

An edit starts, opens the editor component, parses and validates the value, then either saves the commit or cancels and discards.

Open the live example: Inline editing (Editing)

<SvGrid {data} {columns} features={features} enableInlineEditing={true} />

To make a specific column editable, give it an editorType:

const columns: ColumnDef<typeof features, Person>[] = [
  { field: 'firstName',  header: 'First',  editorType: 'text' },
  { field: 'age',        header: 'Age',    editorType: 'number' },
  { field: 'joinedAt',   header: 'Joined', editorType: 'date' },
  { field: 'active',     header: 'Active', editorType: 'checkbox' },
]

A column with no editorType is read-only even when enableInlineEditing={true}.

How a user edits

Action Keys Outcome
Enter edit mode Enter / F2 / double-click Editor opens on the active cell
Commit Enter / Tab Saves the new value
Cancel Esc Discards
Move to next field while editing Tab / Shift+Tab Commits and re-enters edit on the neighbour

What gets saved

When the user commits, the grid:

  1. Parses the editor's string value through parseEditorValue for the column's editorType.
  2. Writes the parsed value into the grid's internal data copy.
  3. Fires onCellValueChange with { rowIndex, columnId, oldValue, newValue, row }.
  4. Fires a re-render.

To round-trip edits to your source, attach a callback:

<SvGrid
  {data} {columns} features={features}
  enableInlineEditing={true}
  onCellValueChange={(e) => savePersonField(e.row.id, e.columnId, e.newValue)}
/>

See Saving values for the full patterns (per-edit, batch-from-snapshot, cascade recompute).

Frequently asked questions

How do I enable inline editing in SvGrid?

Set the inline-editing prop on <SvGrid> and give editable columns an editorType. Then double-click a cell (or press F2), type to replace, and press Enter to commit; Tab moves to the next editable cell.

What cell editors does SvGrid provide?

Built-in editors for text, number, checkbox, date, select, rich-select, and textarea, chosen per column via editorType. You can also supply a custom editor through the cellEditor slot.

Does SvGrid mutate my data array when editing?

No. Commits are written to the grid's internal working copy, not the array you passed in, so cancel/undo is possible. Subscribe to onCellValueChange to persist edits to your own state or backend.

More examples

Cell validation (validate hook)

Declarative per-column validate() hook, Handsontable-style. Invalid cells - including bad data already in the source on load - highlight red with the reason as a tooltip, and re-check live as you edit.

Open the live example: Cell validation (validate hook) (Editing)

Excel-style fill handle

Walks through every fill pattern the engine detects: numeric series, date series, weekday sequence, reverse-fill, horizontal fill, copy-mode.

Open the live example: Excel-style fill handle (Editing)

Drag a range to move or copy it

Grab the border of a selected block and drag it somewhere else and the values move; hold Ctrl (Cmd) as you drop and they are copied. On by default with cell selection - see Drag a range to move or copy it.

Open the live example: Drag a range to move / copy (Editing)

See also

Live examples

  • Inline editing - Typed editors (text/number/checkbox/date) with dirty tracking + save.
  • Cell validation (validate hook) - Declarative per-column `validate()` hook, spreadsheet-style. Invalid cells - including bad data already in the source on load - highlight red with the reason as a tooltip, and re-check live as you edit.
  • Excel-style fill handle - Walks through every fill pattern the engine detects: numeric series, date series, weekday sequence, reverse-fill, horizontal fill, copy-mode.
  • Drag a range to move / copy - Grab the border of a selected block and drag it somewhere else: the values move, or copy when Ctrl / Cmd is held at drop time. The rectangle moves whole or not at all - a drop that would run off the grid or land on a read-only column is refused - and Ctrl+Z walks the whole thing back.

Related articles

  • Paste from Excel into a Svelte Data Grid - How to wire up clipboard paste so users can drop a copied Excel or Google Sheets block directly into SvGrid - TSV parsing, type coercion, validation, and row growth all covered.
  • A Fill Handle (Drag to Fill) in SvGrid - Build a working spreadsheet-style fill handle on top of SvGrid's cell selection and editing - pointer tracking, range highlighting, series fill, and undo/redo integration all covered.
  • An Editable Select / Dropdown Cell in SvGrid - Build a dropdown cell editor in SvGrid using a Svelte 5 snippet - constrain user input to a fixed option set while keeping sort, filter, and undo working on the underlying value.