RowEdit
Feature
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.
// 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
See also
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Set to
trueto update the record as soon as a field is changed. -
Configure this as
trueto dock the editor to the grid's element instead of the browser viewport. -
Internal listeners, that cannot be removed by the user.
-
Set to
trueto start editing when user starts typing text on a focused cell (as in Excel)Has a corresponding runtime autoEdit property.
-
A CSS selector for elements that when clicked, should not trigger editing. Useful if you render actionable icons or buttons into a grid cell.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Delayable class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of RowEdit class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of GridEditBase class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of RowEdit class, or subclass thereof.
-
Returns the record currently being edited, or
null -
Set to
trueto start editing when user starts typing text on a focused cell (as in Excel)Has a corresponding autoEdit config.
-
Is editing currently active?
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.
-
Starts editing if user taps selected cell again on touch device. Chained function called when user clicks a cell.
-
Event handler added when editing is active called when user clicks a cell in the grid during editing. It finishes editing and moves editor to the selected cell instead.
-
Finish editing if clicking below rows (only applies when grid is higher than rows). Also finish if event target is the subgrid which can happen if the pointer is moved during mouse down.
-
Update the input field if underlying data changes during edit.
-
Called when the user triggers the edit action in triggerEvent config. Starts editing.