Disable "Esc" key action when grid is empty

Hi Team,

I am working on a requirement where I want to load grid with empty row, If user press "Esc" key empty row is removed from the grid and as grid is not having toolbar user is not able to add new empty row.

I want to disable "Esc" function on empty row if grid doesn't have any rows. I'm attaching a example below.
Please help me achieving this requirement.

Regards,
Cyril Ovely


Attachment: syncfusion_query_eaec4e46.zip

1 Reply

SK Sujith Kumar Rajkumar Syncfusion Team January 21, 2022 10:59 AM UTC

Hi Cyril, 
 
Greetings from Syncfusion support. 
 
When a new row is added or while editing an existing row, the escape key allows to cancel the add/edit action in the Grid. This is a default keyboard shortcut functionality implemented in the Grid for this case. 
 
However you can disable this action by removing the ‘escape’ key from the Grid’s key configuration in its dataBound event(on initial render alone using a global flag variable) as demonstrated in the below code snippet, 
 
// Grid’s dataBound event handler 
dataBound() { 
    if (this.SO_lineItem_Grid_Loaded) { 
        this.SO_lineItem_Grid_Loaded = false; 
        var grid = this.$refs.SO_lineItem_Grid.$el.ej2_instances[0]; 
        grid.keyConfigs.escape = ""; 
    } 
} 
 
We have modified the shared sample based on this for your reference. You can find it below, 
 
 
Note: The escape key also has other shortcut actions implemented in the Grid like deselection of rows and cells, so removing this will also disable the other shortcut actions for this key. 
 
Please get back to us if you require any further assistance. 
 
Regards, 
Sujith R 


Loader.
Up arrow icon