View as Markdown

Editing

Editing

Row, batch, dialog and cell editing; built-in and custom editors; command column; edit methods and events; saving through the data source; edit marks; confirm prompts; the unsaved-changes guard; undo and redo.

Editing is one prop, editing: true for inline row editing, or settings. editing.edit, editing.add and editing.delete switch the three capabilities. Drafts, flags and errors live in the core edit module, never in React state: a keystroke re-renders the edited cell only.

<DataGrid
  data={orders}
  columns={[
    { field: 'id', header: 'Order', type: 'number', primaryKey: true },
    { field: 'customer', header: 'Customer', validation: { required: true } },
    { field: 'status', header: 'Status', editor: 'select', editorProps: { options: ['Open', 'Shipped'] } },
    { id: 'commands', header: 'Actions', commands: [{ type: 'edit' }, { type: 'delete' }, { type: 'save' }, { type: 'cancel' }] },
  ]}
  editing={{ mode: 'batch', confirmDelete: true, undo: true }}
  toolbar={['add', 'edit', 'delete', 'save', 'cancel']}
  onSave={(event) => console.log(event.status, event.failedRowIds)}
/>

Modes

  • mode: 'row' (default) opens an editor in every editable cell of the row; Enter saves the row.
  • mode: 'dialog' edits the row in a modal form (a native <dialog>: focus trap, inert page, Escape) with a label per field. editing.dialogProps sets the title, width, class and close button; renderDialog, renderDialogHeader and renderDialogFooter replace its parts. While the grid is adaptive the dialog is a full-screen sheet, which is also how vertical card rows edit (see Adaptive UI).
  • mode: 'batch' edits one cell at a time and keeps every change, added row and deleted row as a draft until save() writes them in one request.
  • mode: 'cell' (Salmon UI) writes each cell when its editor closes.

Added rows appear at newRowPosition (top or bottom) with the columns' defaultValue and editing.newRow() values. column.editable: false, the primary key on existing rows and editing.isCellEditable(ctx) make cells read-only; cancel onBeforeEditStart with preventDefault() to refuse one edit. Group captions, group footers, aggregate rows and detail rows are not records and never edit: Enter on a caption expands or collapses it.

Editing needs a row identity: a column.primaryKey column (or getRowId). Without one the grid falls back to the id field and warns in development on the first edit; added rows must carry a key before they save. editing.edit, editing.add and editing.delete set to false refuse the matching keys, toolbar items, command buttons and methods.

Editing

Open demo

Inline row, batch, dialog and cell editing with the built-in editors, a command column, validation messages, edit marks, confirm prompts, the unsaved-changes guard and undo.

Actions
Order
Customer
Category
Qty
Price
Placed
Shipped
Priority
Note (custom editor)
More
ORD-10000
Hana Sato
Brewing equipment
4
$129.00
May 4, 2026, 12:41
Normal
Call before delivery
ORD-10001
Elif Kaya
Loose tea
3
$9.25
Jun 17, 2026, 22:12
Normal
ORD-10002
Goran Petrov
Brewing equipment
6
$64.90
Nov 4, 2026, 14:49
Normal
Leave the parcel with the building reception if nobody answers the door.
ORD-10003
Chen Wei
Brewing equipment
3
$42.00
Jan 22, 2026, 00:05
Normal
Gift wrap
ORD-10004
Elif Kaya
Brewing equipment
4
$42.00
Mar 24, 2026, 00:05
Low
ORD-10005
Bao Nguyen
Brewing equipment
4
$64.90
May 14, 2026, 01:57
High
ORD-10006
Elif Kaya
Brewing equipment
12
$42.00
Apr 3, 2026, 22:58
Normal
ORD-10007
Hana Sato
Coffee beans
10
$14.00
Aug 19, 2026, 14:47
Low
Call before delivery
ORD-10008
Bao Nguyen
Coffee beans
9
$14.00
Dec 25, 2026, 20:14
Normal
Call before delivery
ORD-10009
Bao Nguyen
Coffee beans
8
$14.00
Jun 27, 2026, 15:59
Low
ORD-10010
Jun Park
Brewing equipment
6
$129.00
Dec 2, 2026, 16:10
Low
Call before delivery
ORD-10011
Bao Nguyen
Loose tea
1
$9.25
Sep 8, 2026, 02:27
High
ORD-10012
Hana Sato
Coffee beans
8
$18.50
Aug 24, 2026, 03:55
High
ORD-10013
Farah Aziz
Loose tea
7
$12.75
Jul 25, 2026, 02:42
High
ORD-10014
Chen Wei
Brewing equipment
9
$64.90
Nov 5, 2026, 18:07
Normal
Leave the parcel with the building reception if nobody answers the door.
ORD-10015
Jun Park
Brewing equipment
1
$64.90
Oct 10, 2026, 05:56
Low
Leave the parcel with the building reception if nobody answers the door.
ORD-10016
Jun Park
Loose tea
8
$9.25
Feb 10, 2026, 09:45
Low
Call before delivery
ORD-10017
Chen Wei
Loose tea
6
$12.75
Jan 20, 2026, 13:14
High
Gift wrap
ORD-10018
Chen Wei
Loose tea
6
$9.25
Mar 1, 2026, 20:57
High
Gift wrap
ORD-10019
Goran Petrov
Brewing equipment
7
$42.00
Jan 6, 2026, 07:03
High
Call before delivery
No events yet.

Starting and ending an edit

Double click (editOnDoubleClick), F2, the toolbar edit item or the command column start an edit. The keyboard works as follows: Enter saves (batch: saves the cell and edits the cell below; Shift+Enter the cell above), Tab and Shift+Tab move between editable cells (tabToNextRow continues on the next row), Insert (Ctrl+⌘+Enter on macOS) adds a row, Delete deletes the selected rows, Escape cancels and returns focus to the cell. confirmDelete asks before deleting (default off), confirmDiscard before discarding a batch from Cancel or a guarded action (default on; confirmDiscard: false discards at once), and confirmSave before a toolbar or menu Save of a batch with pending changes (default on; confirmSave: false saves at once; api.save() never asks). Prompt texts are the confirmDelete, confirmDiscard and confirmSave locale keys. The methods startEdit, save, saveCell, cancelEdit, addRow, deleteRows, updateRow, updateCell and getPendingChanges mirror these actions; in batch mode save() writes and cancelEdit() discards every pending change. applyChanges({ added, changed, deleted }) updates many records at once without the edit lifecycle, and setCellValue / setRowData change one cell or row silently. Each method returns a result (applied, rejected with a reason, or async); while the lazily loaded editing code is still loading, methods return async, so call them from onReady at startup.

Each action raises a cancelable before-event and an after-event: onBeforeEditStart / onEditStart, onBeforeCellValueChange / onCellValueChange, onBeforeSave / onSave, onBeforeAdd / onAdd, onBeforeDelete / onDelete, onBeforeEditCancel / onEditCancel, and onCommandClick.

onBeforeSave fires before the write is sent to the data source and can cancel it; onSave fires once the write settled. Its status is 'applied', 'partial', 'rejected' or 'error' ('pending' in the before-event), with the source's result (a WriteResult, or null), the thrown error (or null) and the failedRowIds that keep their drafts; rows() returns the written rows. A failed save or delete also fires onError with action: 'save'.

Edit methods and events

Open demo

The editing capability flags, newRowPosition, tabToNextRow, read-only columns and isCellEditable, every edit method on the Data Grid instance and every edit event in a log.

Order
Customer
Country (read-only)
Qty
Price
Shipped
Priority
ORD-10000
Hana Sato
Portugal
5
$64.90
Normal
ORD-10001
Bao Nguyen
Japan
9
$42.00
Normal
ORD-10002
Goran Petrov
Germany
8
$42.00
Normal
ORD-10003
Farah Aziz
France
1
$14.00
Normal
ORD-10004
Goran Petrov
France
10
$64.90
Normal
ORD-10005
Bao Nguyen
Malaysia
7
$42.00
Normal
ORD-10006
Bao Nguyen
France
10
$14.00
High
ORD-10007
Elif Kaya
Malaysia
11
$129.00
Normal
ORD-10008
Elif Kaya
France
7
$129.00
High
ORD-10009
Bao Nguyen
Germany
7
$12.75
Normal
ORD-10010
Ines Duarte
Malaysia
8
$64.90
Normal
ORD-10011
Chen Wei
Portugal
4
$14.00
Normal
ORD-10012
Farah Aziz
Portugal
3
$18.50
High
ORD-10013
Hana Sato
France
1
$14.00
High
ORD-10014
Hana Sato
Portugal
9
$129.00
Low
ORD-10015
Aiko Tan
Portugal
4
$42.00
Normal
ORD-10016
Dewi Lestari
Malaysia
4
$14.00
High
ORD-10017
Hana Sato
Germany
10
$14.00
Normal
ORD-10018
Bao Nguyen
France
3
$14.00
Low
ORD-10019
Farah Aziz
Portugal
4
$129.00
Normal
No events yet.

Command column

A column with commands renders buttons in every row and is never edited itself:

{ id: 'commands', header: 'Actions', commands: [{ type: 'edit' }, { type: 'delete' }, { type: 'save' }, { type: 'cancel' }] },
{ id: 'more', header: 'More', commands: [{ type: 'custom', label: 'Details' }] },

Edit and Delete show while the row is idle, Save and Cancel while it edits, and custom buttons always. Each item takes a label (default: the localized command name), an icon, a title and, for custom, an onClick({ rowId, row }). onCommandClick receives { command, rowId, row } for every button first; preventDefault() cancels the built-in command.

Editors

column.editor picks a built-in editor: text, number, select, checkbox, date or datetime; without it the column type decides. column.editorProps configures it, for example the select options, min / max / step of the number editor (ArrowUp and ArrowDown step within the range; a typed number outside it is clamped on save or blur), the picker range of the date editors, and minLength / maxLength of the text editor. Lookup columns edit their key with a select of the lookup rows and show the display value. column.renderEditor(ctx) renders any editor; spread ctx.inputProps on the focusable element to keep the ids, ARIA wiring and focus.

Column validation rules, custom validators and editing.validateRow gate every save; see Validation.

Saving to a server

Every save (a row, a cell, or a whole batch) is one call of the data source's write({ added, changed, deleted }) with the rows and their changed columns. There are no per-operation URL options: wrap your endpoint in write, or use a @salmonui/data source, which speaks the Salmon UI JSON protocol. While the request runs the cells carry data-pending. A partial result applies the accepted rows and keeps the rejected ones as drafts with the server's cellErrors / rowErrors as messages; a thrown error or a rejected result keeps every draft, so the user can fix and save again. getEditSnapshot() reads the current cell and row errors.

const source: DataSource<Order> = {
  mode: 'local',
  read: (request) => store.read(request),
  subscribe: (listener) => store.subscribe(listener),
  async write(request) {
    const { added, changed, deleted } = request;
    const response = await fetch('/api/orders/batch', { method: 'POST', body: JSON.stringify({ added, changed, deleted }) });
    return response.json(); // { version, status, changed?, cellErrors?, ... }
  },
};

Saving to a server

Open demo

Batch saves go to dataSource.write as one request with added, changed and deleted rows; a simulated server rejects some cells or fails, and the grid keeps the drafts with the server errors.

Order
Customer
Country
Qty
Amount
No records to display

Edit a few customers (type “reject” in one), then Save: one request carries every change. Pending cells show while the request runs; rejected cells keep their draft with the server message.

No events yet.

Batch mode works with row and column virtualization. Drafts, delete marks and added rows are keyed by row id in the core, so an edited row keeps its draft and marks after it scrolls out of the DOM and back, and an open editor comes back with its text. Enter, Shift+Enter, Tab and Shift+Tab move through the row model, scroll the next cell into view and focus its editor when it mounts; save() and cancelEdit() cover rows that are not rendered.

Batch editing over 100,000 rows

Open demo

Batch mode with row virtualization; drafts survive scrolling, and group captions stay read-only when the rows are grouped.

Order
Customer
Country
Product
Qty
Amount
ORD-10000
Jun Park
Japan
Kettle
4
$259.60
ORD-10001
Aiko Tan
Germany
Filter beans
5
$59.50
ORD-10002
Bao Nguyen
France
Grinder
7
$857.85
ORD-10003
Aiko Tan
Malaysia
Oolong tea
9
$103.28
ORD-10004
Farah Aziz
Portugal
Pour-over kit
5
$199.50
ORD-10005
Bao Nguyen
Malaysia
Espresso beans
6
$99.90
ORD-10006
Bao Nguyen
France
Grinder
8
$877.20
ORD-10007
Jun Park
Malaysia
Grinder
5
$645.00
ORD-10008
Farah Aziz
Malaysia
Filter beans
9
$119.70
ORD-10009
Aiko Tan
Malaysia
Grinder
11
$1,206.15
ORD-10010
Ines Duarte
Malaysia
Pour-over kit
10
$399.00
ORD-10011
Dewi Lestari
Germany
Grinder
1
$109.65
ORD-10012
Hana Sato
Malaysia
Kettle
8
$441.32
ORD-10013
Bao Nguyen
Japan
Kettle
2
$116.82
ORD-10014
Aiko Tan
France
Espresso beans
6
$111.00
ORD-10015
Jun Park
Malaysia
Pour-over kit
9
$359.10
ORD-10016
Jun Park
Malaysia
Espresso beans
5
$78.63
ORD-10017
Goran Petrov
Malaysia
Grinder
11
$1,277.10
ORD-10018
Farah Aziz
Japan
Green tea
7
$58.28
ORD-10019
Dewi Lestari
Malaysia
Filter beans
10
$133.00

Edit a cell, scroll to the end and back: the draft and its mark stay. Group captions expand and collapse on Enter; they never open an editor.

No events yet.

Always-visible add row

editing.showNewRow keeps a blank add row at newRowPosition in row mode. It shows its editors at rest and is already in the server markup (empty cells until the editing code loads). Type into it and press Enter, use Save, or Tab past its last cell to write the record; a fresh blank row follows and takes focus, so entry continues row after row. Escape clears it and returns focus to the grid; leaving it untouched writes nothing. While another row edits, the add row is disabled (aria-disabled, disabled editors). Insert, the toolbar add item and addRow(values) fill this row instead of opening a second one; it cannot be deleted, and it counts as an unsaved change only once a value changed. Batch, dialog and cell modes ignore it (a development warning says so). Under virtual scrolling it stays at bottom too: the added-rows band is sticky.

Always-visible add row

Open demo

editing.showNewRow keeps a blank add row at newRowPosition; Enter saves it and a fresh one follows.

Order
Customer
Country
Qty
Shipped
ORD-10000
Aiko Tan
France
7
ORD-10001
Hana Sato
Germany
9
ORD-10002
Bao Nguyen
Japan
5
ORD-10003
Farah Aziz
Malaysia
8
ORD-10004
Goran Petrov
Malaysia
6
ORD-10005
Chen Wei
Japan
12
ORD-10006
Jun Park
Japan
4
ORD-10007
Chen Wei
Japan
11
ORD-10008
Aiko Tan
France
2
ORD-10009
Dewi Lestari
Germany
1
ORD-10010
Chen Wei
Japan
2
ORD-10011
Farah Aziz
Germany
6
ORD-10012
Hana Sato
Germany
2
ORD-10013
Jun Park
Japan
12
ORD-10014
Aiko Tan
France
8
ORD-10015
Hana Sato
Malaysia
3
ORD-10016
Farah Aziz
France
3
ORD-10017
Jun Park
Malaysia
12
ORD-10018
Chen Wei
Malaysia
5
ORD-10019
Goran Petrov
Japan
5

Type an order id and a customer in the add row, press Enter: the order is saved and a fresh add row takes focus. Double click another row: the add row is disabled until that edit ends.

No events yet.

Marks, guard and undo

Changed cells, invalid cells, pending writes, added rows and deleted rows carry data-dirty, data-invalid, data-pending, data-new and data-deleted; getBatchPreview() lists the diff for a review UI. With unsaved changes, editing.guardUnsaved (on by default in batch mode) asks before sorting, filtering, searching, paging or grouping discards them, and warns on page unload. editing.undo records edits for undo() / redo() and Ctrl/⌘+Z / Ctrl/⌘+Y (also Ctrl/⌘+Shift+Z), keeping undoLimit entries (default 10).

Formulas

The grid has no formula cells: a reference grammar, dependency graph and recalculation pass are spreadsheet territory and would sit on the edit path. A value computed from other fields of the same row is a computed column, column.valueGetter(row), which sorts, filters, groups, aggregates and exports like any column. When the exported workbook must keep a live formula, return it from the XLSX export cell hook: cell: (ctx) => ({ formula: 'B2*C2' }) (Export; the export demo writes its Stretch column as a formula). Cross-row or user-entered formulas belong in a spreadsheet component.

API reference

See DataGridEditing, DataGridEditColumn, DataGridCommandItem, DataGridSaveEvent and the edit methods of DataGridApi in the API reference.