RowEdit

This feature allows editing of entire rows in a grid in a docked panel which by default slides out from the right.

By default, the editor is docked to the browser viewport, but it can be configured to be local to the grid.

The input fields are generated from the columns in the grid in the same way as the CellEdit, and the editor is a Panel.

Row editing
//<code-header>
fiddle.title = 'Row editing';
//</code-header>
// grid with row editing
const grid = new Grid({
    appendTo : targetElement,

    height : 600,

    features : {
        // cellEditing is enabled by default, so this is necessary
        cellEdit : false,
        rowEdit  : {
            // Dock the editor into the grid's element, not the browser viewport
            local : true
        }
    },

    showDirty : true,

    tbar : {
        items : {
            instantUpdate : {
                type     : 'checkbox',
                text     : 'Instant Update',
                tooltip  : 'Update record instantly after editing',
                value    : false,
                onChange : ({ checked }) => {
                    grid.features.rowEdit.instantUpdate = checked;
                }
            }
        }
    },

    data : DataGenerator.generateData(5),

    columns : [
        // basic columns has a TextField as editor by default
        {
            field            : 'name',
            text             : 'Name',
            flex             : 1,
            // Invoked on final edit of input field, typically after pressing enter or blurring the field.
            finalizeCellEdit : ({ value }) => {
                // returning true will accept the new value otherwise it shows the return statement as error message
                return value.trim().length < 5 ? 'Name should be at least 5 characters' : true;
            }
        },
        // a custom editor can be specified
        {
            field  : 'city',
            text   : 'City',
            flex   : 1,
            editor : {
                type  : 'combo',
                items : ['Stockholm', 'New York', 'Montreal']
            }
        },
        // column types may specify an editor
        // NumberColumn for example uses a NumberField
        {
            type             : 'number',
            field            : 'score',
            text             : 'Score',
            flex             : 1,
            finalizeCellEdit : ({ value, record }) => {

                // record contains sibling column's data
                const { city } = record;

                // Perform validation based on a sibling column
                if (city === 'Paris' && value > 999) {
                    return "Score can't be higher than 999 for Paris";
                }
                return true;
            }
        },
        // specify editor: false to make a column "readonly"
        { type : 'number', field : 'age', text : 'Age (readonly)', flex : 1, readOnly : true }
    ]
});

By default, the editor works in batch mode. Fields are changed, and when the "Save" button is clicked (or the Enter key pressed), the record is updated with all the changes.

The editor can be configured to update the record as soon as a field is changed by setting the instantUpdate config to true.

Note that the revertOnEscape property of columns is respected, so pressing Escape will revert the field to the value of the field on focus.

Pressing Escape on a field which has not been changed will cancel the edit and close the editor.

To start editing a row, double-click a cell in the row, or press Enter or F2 when a cell is focused.

The start gesture can be configured by setting the triggerEvent config to 'cellClick' or 'cellDblClick'.

Editing can be prevented by setting the ignoreCSSSelector config to a CSS selector which matches elements that should not trigger editing.

Pressing Enter or clicking the "Save" button will save the changes and close the editor. Pressing Escape or clicking the "Cancel" button will close the editor without saving changes.

If instantUpdate is true, the record will be updated as soon as a field is changed (on blur or when changed by trigger action such as spin up or down in a number or date or time field), so Escape and the "Cancel" button revert the changes before closing the editor.

Clicking outside the editor will normally cancel the ongoing edit and start a new one on the clicked cell. This can be prevented by setting the continueEditingOnCellClick config to false.

This feature is disabled by default

Configs

22

Common

disabledInstancePlugin
listenersEvents

Other

The Panel instance used as the editor.

editorSize: Number | String= '30em'

The width of the editor. (Or height if side is 'top' or 'bottom').

May be specified as a number of pixels or a CSS length string.

focusContextualField: Boolean= true

By default, the editor field corresponding to the cell clicked will be focused when starting editing.

Set to false to prevent this. Focus will then go to the first field in the editor.

if autoEdit is true, starting editing by typing will always focus the contextual field in the editor.

instantUpdate: Boolean

Set to true to update the record as soon as a field is changed.

local: Boolean= false

Configure this as true to dock the editor to the grid's element instead of the browser viewport.

revertButton: Boolean= false

Configure this as true to show a "Revert" button in the editor which reverts any unsynced changes to the record.

This reverts all changes made since the data was loaded or synchronized with the server. This is different to just canceling an ongoing edit. This reverts the record to its loaded state.

The button is only shown when starting an edit on a record which has unsynced changes.

side: start | left | end | right | top | bottom= 'end'

The side of the grid where the editor will be shown.

'start' means the inline-start side. 'end' means the inline-end side.

titleField: String

The name of the field from the record to use when generating the title for the editor.

The default implementation returns "Editing " plus the value of the named field from the editing record.

titleRenderer: function

A function (or the name of a function) which will be called passing the editing record to generate the title for the editor.

You should never modify any records inside this method.

The default implementation returns "Editing " (localized according to the current locale) plus the value of the field specified in titleField.

This may be configured if a more sophisticated title is required.

ParameterTypeDescription
recordModel

The record being edited

Returns: String -

The title for the editor

autoEditGridEditBase
ignoreCSSSelectorGridEditBase
triggerEventGridEditBase

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

21

Common

disabledInstancePlugin

Class hierarchy

isRowEdit: Boolean= truereadonly
Identifies an object as an instance of RowEdit class, or subclass thereof.
isRowEdit: Boolean= truereadonlystatic
Identifies an object as an instance of RowEdit class, or subclass thereof.
isDelayableDelayable
isEventsEvents
isGridEditBaseGridEditBase
isInstancePluginInstancePlugin
isLocalizableLocalizable

Other

The Panel instance used as the editor.

activeRecordGridEditBase
autoEditGridEditBase
isEditingGridEditBase

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

32

Editing

Cancel editing, hides the editor. This function is exposed on Grid and can thus be called as grid.cancelEditing(...)

ParameterTypeDescription
isStartingBoolean

Pass true to indicate that the cancel is due to a new edit starting

Returns: Boolean -

false if the edit could not be canceled due to the beforeCancelRowEdit event being prevented.

Start editing specified row. If no cellContext is given it edits the first visible row. This function is exposed on Grid and can thus be called as grid.startEditing(...).

ParameterTypeDescription
cellContextGridLocationConfig

Cell specified in format { id: 'x', columnId/column/field: 'xxx' }. See getCell for details.

isAutoEditBoolean

Pass true to indicate that the edit is due to a keydown event with autoEdit set to true. In this case the editor field corresponding to the cell context will be cleared for the keypress to take effect upon focus.

Returns: Promise -

Resolved promise returnstrue if editing has been started, false if an beforeStart listener has vetoed the edit.

Other

Finish editing, update the underlying record and hide the editor. This function is exposed on Grid and can thus be called as grid.finishEditing(...)

Returns: Promise -

Resolved promise returns false if the edit could not be finished due to an input field being invalid or the beforeFinishRowEdit event was prevented.

createOnFrameDelayable
LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Events

10

Fires on the owning Grid before the row editing is canceled, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be reset to initial values on cancel of editing.

// Adding a listener using the "on" method
rowEdit.on('beforeCancelRowEdit', ({ grid, editorContext }) => {

});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Fires on the owning Grid before the row editing is finished, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be updated as soon as a field is changed, so this event would not prevent the record from being updated, only the editor being hidden.

// Adding a listener using the "on" method
rowEdit.on('beforeFinishRowEdit', ({ grid, editorContext }) => {

});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Fires on the owning Grid before editing starts, return false to prevent editing

// Adding a listener using the "on" method
rowEdit.on('beforeStartRowEdit', ({ source, editorContext }) => {

});
ParameterTypeDescription
sourceGrid

Owner grid

editorContextRowEditorContext

Editing context

Fires on the owning Grid before the row editing is finished, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be updated as soon as a field is changed, so this event would not prevent the record from being updated, only the editor being hidden.

// Adding a listener using the "on" method
rowEdit.on('finishRowEdit', ({ grid, editorContext }) => {

});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Fires on the owning Grid when editing starts

// Adding a listener using the "on" method
rowEdit.on('startRowEdit', ({ source, editorContext }) => {

});
ParameterTypeDescription
sourceGrid

Owner grid

editorContextRowEditorContext

Editing context

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

10

Called on the owning Grid before the row editing is canceled, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be reset to initial values on cancel of editing.

new RowEdit({
    onBeforeCancelRowEdit({ grid, editorContext }) {

    }
});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Called on the owning Grid before the row editing is finished, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be updated as soon as a field is changed, so this event would not prevent the record from being updated, only the editor being hidden.

new RowEdit({
    onBeforeFinishRowEdit({ grid, editorContext }) {

    }
});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Called on the owning Grid before editing starts, return false to prevent editing

new RowEdit({
    onBeforeStartRowEdit({ source, editorContext }) {

    }
});
ParameterTypeDescription
sourceGrid

Owner grid

editorContextRowEditorContext

Editing context

Called on the owning Grid before the row editing is finished, return false to signal that the value is invalid and editing should not be finalized.

Note that if instantUpdate is true, the record will be updated as soon as a field is changed, so this event would not prevent the record from being updated, only the editor being hidden.

new RowEdit({
    onFinishRowEdit({ grid, editorContext }) {

    }
});
ParameterTypeDescription
gridGrid

Target grid

editorContextRowEditorContext

Editing context

Called on the owning Grid when editing starts

new RowEdit({
    onStartRowEdit({ source, editorContext }) {

    }
});
ParameterTypeDescription
sourceGrid

Owner grid

editorContextRowEditorContext

Editing context

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

3

Row editing context

ParameterTypeDescription
editorPanel

The Panel being used. Will contain an inputField property, which is the field being used to perform the editing

columnColumn

Target column

recordModel

Target record

cellHTMLElement

Target cell