Categories | Question details Back To List | ||
Is there a way to detect
that the user pressed 'Escape' instead of 'Enter' during a cell edit ? That
way... Is there a way to detect that the user pressed 'Escape' instead of 'Enter' during a cell edit ? That way, we can restore the old cell value. Answer posted on Mar 07, 2007 11:29 In current version (1.2), the
Esc generates the same event as any other editor closing event, there is no way
to detect which event causes editor closing. Answer posted by Darren Bowen on May 30, 2007 12:50 I would really like to see the ability to cancel edits in a future version too. I have managed to get this semi-working as follows: myGrid.attachEvent('onKeyPress',KeyPressed);"; function KeyPressed(code,ctrl,shift){ // If escape key pressed (and currently in edit mode) if ((myGrid.editor) && (code==27)) { // Then user pressed escape. // myGrid.editCancel(); } return true; } To restore the original value, you might try something like this, this function doesn't work with every ex-cell type, but should be ok with basic text editors. Just un-comment the line myGrid.editCancel(); above. dhtmlXGridObject.prototype.editCancel = function() { // Keep a reference to the editor (because this.editor is lost when we do this.editStop();) var editor = this.editor; // Remember the old value of the cell var val= editor.val; // Set the table cell value to the editor value, so the grid thinks that the cell hasn't changed. editor.val = editor.getValue(); // Stop the editing process this.editStop(); // Restore the current value editor.setValue(val); } Answer posted by Alexandra (Support) on Dec 02, 2014 15:36 If you haven't found the needed information there and still looking for a solution, you will find the additional help checking progress bar javascript example and php ajax select. |