0
votes

I have an ExtJS 4 editable grid that has two editable columns (a date column and a normal text column). By default I display a date and a text in each column when the grid is loaded. I would like to erase the information that is displayed when the user clicks on the cell to edit its content. When the user clicks out (without modifying anything) I want to revert back to the original data that was displayed in the field.

Any idea how to achieve that?

I tried the following but it didn't work:

Ext.getCmp('my_grid').on('beforeedit', function(editor, e, eOpts) {

    e.record.value = "";

});    

Thanks for any help

1

1 Answers

0
votes

You have to use both beforeedit & validateedit listeners to achieve this.

beforeedit will be used to clear the value.

validateedit will revert to previous value if no value is entered by returning false

validateedit: {
                fn: function(event,editor){ 
                    if(!editor.value)
                        return false;
                    else 
                   return true;

             }
        },
             beforeedit: {
                fn: function(event,editor){ 
                    editor.value=null;
                    return true;
                }

        }