Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: pass the row object to the editorArgs function #1446

Merged
merged 9 commits into from
Jan 9, 2020
4 changes: 3 additions & 1 deletion Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ define([

args = column.editorArgs || {};
if (typeof args === 'function') {
args = args.call(this, column);
// `object` is undefined for shared editors, but for always-on
// editors it will be the row data.
args = args.call(this, column, object);
}

if (Widget) {
Expand Down
2 changes: 1 addition & 1 deletion doc/components/mixins/Editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Property | Description
-------- | -----------
`editor` | The type of component to use for editors in this column; either a string specifying a type of standard HTML input to create, or a Dijit widget constructor to instantiate. If unspecified, the column will not be editable.
`editOn` | A string containing the event (or multiple events, comma-separated) upon which the editor should activate. If unspecified, editors are always displayed in this column's cells.
`editorArgs` | An object containing input attributes or widget arguments. For HTML inputs, the object will have its key/value pairs applied as attributes/properties via `dojo/dom-construct.create`; for widgets, the object will be passed to the widget constructor.
`editorArgs` | An object containing input attributes or widget arguments. For HTML inputs, the object will have its key/value pairs applied as attributes/properties via `dojo/dom-construct.create`; for widgets, the object will be passed to the widget constructor. Alternatively, `editorArgs` can be a function returning this object. It should have the signature `editorArgs(column, rowObject)`. The `rowObject` parameter is only defined for always-on editors.
`canEdit(object, value)` | A function returning a boolean value indicating whether or not the cell for this column should be editable in a particular row. Receives the item for the current row, and the value to be rendered (i.e. the return from the column's `get` function if any, or the value of the `field` specified in the column).
`autoSave` | If `true`, the grid's `save` method will be called as soon as a change is detected in an editor in this column. Defaults to `false`. **Note:** if an error is encountered as a result of a store operation triggered by `autoSave`, a `dgrid-error` event will be emitted.
`autoSelect` | If `true` and `editor` is `'text'` or a `TextBox`-based widget, the contents of the field will be selected when the editor is activated/focused.
Expand Down