Prevent "Escape" From Grid Row Edit?

There are a few things that appear to “cancel” a row edit without the otherwisea pplicable grid row events being triggered. For example, onRowSelect, onEditCell, and others. This means that programmatic tasks pertaining to inline row edits may be left incomplete and very likely in error when, for example, a toolbar button is clicked, or a tab selected, or the ESC key entered. Is there a way to address this, or is it up to the programmer (me, that is) to make changes to disable all other controls or forms, buttons, links, and so on, as well as to capture and ignore the grid’s ESC keypress event (assuming this event is triggered by the ESC key, of course)?

to “cancel” a row edit without the otherwisea pplicable grid row events being triggered

When row editing is canceled by any action - onEditCell will be called. It doesn’t possible to close editor without triggering such event.

Grid can’t block editor closing, if some action occurs ( selection, other editor activation etc. ) - currently active cell will be closed, but you can handle onEditCell event and process new value of cell in necessary way, and if it necessary focus the same cell again and switch it back to edit state.

Thanks, Stanislav, for this additional information. I have confirmed most of what you shared. The ESC key, however, does not trigger the onEditCell event – and probably shouldn’t since using the ESC key is generally treated as a “cancel” action and, in this case, a natural way someone would expect to cancel an inline edit.

Is there a grid event that can be triggered by this logical edit cancellation??

I have seen that I can trap the ESC key using the onKeypress event for the grid. Since I have modified cell styles during the inline edit process (onEditCell stage 0) I can then cancel these actions as well as part of trapping the ESC key, as I would normally do at onEditCell stage 2, as well as clearing some other internal settings that pertain to an edit being in process. I could even confirm the user’s intent to cancel, or simply issue an alert that says “Edit canceled.”

I know that somewhere the previous “old” field values are saved as part of the grid edit process. There is, is there not, a method that allows these values to be returned so that, as part of processing the ESC key event that old values can be be used to reset the row?


There is no a separate event, but next can be used

var old = grid.editStop; grid.editStop = fucntion(mode){ if (mode && this.editor){ //exec any custom logic here //this.editor.val - old value of the cell } return old.apply(this,arguments); }

Above code snippet will wrap editor closing code, and will allow to run some custom code each time when active editor is closing by escape.

I believe I understand what this is about, but I’m not certain it addresses the issue I’m exploring. Suppose the row has 3 cells. User edits cell 1, then cell 2, and is in cell 3 when he/she decides, “Oops, wrong row” and hits the ESC key. It appears that the editStop(true) could be invoked to return cell 3 to it’s former value, but I think I need to also be able to return cells 1 and 2 to their former values. What it’d like to accomplish is either (1) allow ESC key to “abort” the entire row’s edit, or (2) pop up a confirmation window “Are you sure you’d wish save your changes” (or whatever) that allows for a “No” response - in which case, again, I’d need to restore the previous values for each cell. I’m thinking you folks long ago provided a mechanism for this, but I’m failing to see it. Thanks again for all your help!

allow ESC key to “abort” the entire row’s edit
This is problematic, grid doesn’t store old cell values, so you need to use custom onEditCell handler, which will store old values for the cells and restore them when necessary. It sounds as complicated scenario.

The cell edit logic allows to block or revert single row edit operations, but it doesn’t capable to revert whole row, at least not without extensive custom event handling.

Thanks to your help I have successfully handled this, and without much trouble, really. If at any cell edit the user hits the ESC key, all editable field values are restored, and an informative message appear, to the effect that “Modification of xxxx has been cancelled.”