• props (String) - Set of properties defined on the Dijit Widget
• fromEditor (function(storeData, gridData)) – Function to be called to return the value
from the editor.
• toEditor (function(storeData, gridData, cell, editor)) - Function is called to populate the
editor widget. The editor parameter is a reference to the Dijit widget used to edit the cell.
• constraints (Object) - Additional properties passed to the editor.
• useGridData (Boolean) - Should the editor be fed with data from the Store or from the
Grid? The default is false which means to use the store data. This property is not used if
toEditor is supplied.
• valueField (String) - The property of the editor that holds the value. This is normally
value which is the default.
When the edit of the cell has finished, the data entered is written back into the store. We can
change how this is achieved by providing a function to be called to apply the change using our own
logic. The property for this is customApplyEdit which is a function with the signature
function(cell, value). It is the responsibility of the code to set the value of the cell to be the value
passed in as a parameter.
Here is an example of a simple editable grid
var layout = [
{
…
"editable": true
…
}
];
var grid = new Grid({
…
"structure": layout,
"modules": [Edit],
…
});
By adding Edit to your grid, the cell object has some additions included:
• editor() - returns the Dijit widget that is used to display the editing
Events are also added including
• onBegin(cell) - called when editing begins.
• onApply(cell, applySuccess) - called after the changes made by editing have
been applied. applySuccess is true if the application of the changes was successful.
• onCancel(cell) - Called when editing of the cell is canceled.
To add an event handler, the following may be used:
myGrid.edit.connect(myGrid.edit, "onBegin", function(cell) {...});
Let us now look at an example:
{ field: 'color', name: 'Color', width: '10em', editable: true,
decorator: function(data){
return [
'<div style="display: inline-block; border: 1px solid black; ',
'width: 20px; height: 20px; background-color: ',
data,'"></div>'
].join('');
Page 183
Kommentare zu diesen Handbüchern