Row edit panel
Since 1.6.0
The rowEditPanel option and openRowPanel, closeRowPanel, getRowPanelState and saveRowPanel are available from 1.6.0. They need the editing bundle.
Rows with many columns are awkward to edit cell by cell. With rowEditPanel on, one row opens in a form docked beside the grid. Each field uses the column's editor (text, number, select, date, checkbox, multi-line …), so the same input rules apply as when you edit the cell directly.
createGrid(container, {
columns, // columns with editable: true become fields of the form
rows,
rowKey: 'id',
rowEditPanel: true, // double-click a row to open the form
});Try it in the gallery example Edit a row in a side form.
Options
rowEditPanel is false (default), true (all defaults) or an object.
| Key | Default | Meaning |
|---|---|---|
position | 'end' | Where the panel sits. 'end' is the right side in LTR and the left in RTL, 'start' is the opposite. 'bottom' is below the grid |
size | 360 | Width in px (height for 'bottom'). At least 200 |
fields | every editable column | Column ids to show, in order. A column that cannot be edited is shown as read-only text |
open | 'dblclick' | How the panel opens. 'dblclick': double-click a data row (instead of editing the cell). 'select': select one row. 'api': only openRowPanel |
modal | false | true floats over the grid instead of pushing it. In a container narrower than 640px it always opens as a bottom sheet |
rowTitle | value of the first text column | (row) => string. The title in the panel header |
A bad value is rejected with invalid-option before anything changes. setOptions can turn it on and off; turning it off closes an open panel.
The form and saving
- Every field has a label. Fields with
validation.requiredcarry a*(screen readers say "Required"). - A cell that cannot be edited on this row (an
editablefunction returningfalse) is shown as read-only text. - Changing a value shows an Unsaved changes marker in the header.
- Save (Ctrl+Enter or the button) applies only the changed fields at once. Validation,
beforeEdit, theeditCommittedevent and change tracking run per cell exactly as for a direct edit, and undo is one step. - If any rule fails nothing is saved. Each failing field shows why and focus goes to the first one. The same
validationFailedevent as a cell edit is raised. - After saving the panel closes and focus returns to the grid cell. With nothing changed it just closes.
Opening and closing
| To do | How |
|---|---|
| Open | Double-click a row (open: 'dblclick'), select a row (open: 'select'), api.openRowPanel(rowKey) |
| Move to another row | The Previous row and Next row buttons, or open another row |
| Save | The Save button, Ctrl(⌘)+Enter, api.saveRowPanel() |
| Close | The Cancel or × button, Esc, a click on the backdrop, api.closeRowPanel() |
Opening another row or closing with unsaved values first asks the beforeRowPanelClose hook. Without the hook, or if it returns anything but false, the edited values are discarded. closeRowPanel({ discard: true }) discards without asking.
hooks: {
beforeRowPanelClose: ({ rowKey }) =>
confirm(`Discard the unsaved values of row ${rowKey}?`), // false keeps the panel open
}API
| Method | Description |
|---|---|
openRowPanel(rowKey) | Opens the panel. Returns false if a hook blocks it. Throws for an unknown row, and with invalid-option if rowEditPanel is off |
closeRowPanel(opts?) | Closes the panel. { discard: true } drops edited values without asking. Returns false if it is not open or a hook blocks it |
getRowPanelState() | { open, rowKey, dirty, invalid }. invalid lists the column ids that currently fail validation |
saveRowPanel() | Saves the changed fields at once. Returns false if validation fails or a hook blocks it |
Events and hooks
| Name | Kind | Content |
|---|---|---|
rowPanelOpened | event | { rowKey } |
rowPanelClosed | event | { rowKey, reason }. reason is 'save', 'cancel', 'api' or 'switch' |
rowPanelSaved | event | { rowKey, changes }. changes has { from, to } per column id |
beforeRowPanelOpen | hook | { rowKey, previousKey }. false keeps it closed |
beforeRowPanelSave | hook | { rowKey, changes }. Called after validation, just before saving. false skips the save |
beforeRowPanelClose | hook | { rowKey, dirty, reason }. Called only with unsaved values. false keeps the panel open |
Keyboard
| Key | Action |
|---|---|
| Tab / Shift+Tab | Cycle inside the panel only |
| Enter | Go to the next field (not in a multi-line field or on a button) |
| Ctrl(⌘)+Enter | Save (also from inside a multi-line field) |
| Esc | Closes an open list or calendar first, otherwise cancels |
Position and narrow screens
'end'and'start'shrink the grid by the panel width;'bottom'makes the grid as much lower. The outer size of the grid does not change when the panel opens or closes.modal: truefloats over the grid without pushing it (role="dialog", a click on the backdrop cancels).- A container narrower than 640px always opens a bottom sheet (dialog), whatever
modalsays. - With
direction: 'rtl','end'and'start'swap. Dark theme, forced colors and the languages (ko, en, ja, zh) are followed.
Accessibility
The panel is a named complementary region (a dialog when it overlays). Opening moves focus to the first field and closing returns it to the grid cell. Opening, saving and validation failures are announced to screen readers.
Good to know
- While the panel is open, changes made to the same row elsewhere are not re-read into the form. Saving overwrites only the fields you changed in the form.
- There are no slots yet to customise a field (such as
rowPanelField). In React, Vue and Angular just pass the option through. - The older form panel example (master-form) shows how to build one by hand with a detail panel. From 1.6.0 this option is simpler.