Is there a way to detect that the user pressed 'Escape' ins

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.

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.

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():wink:
    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);

}

Hi,
It doesn’t work with “txt” type. I have been successful with “ed” type but with “txt” no.
why and what can I do?

regards,

You can attach “esc” button handler with custom eXcell. Check tutorial here docs.dhtmlx.com/doku.php?id=dhtm … l_creation