Enter key behavior

Olá,

How can I change the Enter key behavior in ej-grid? And where I can find the complete documentation of keyboardModule?

Just for knowlege, I wan't to do nothing when I pressing the Enter key, in other words, the default behavior of Enter key in ej-grid is go for next row, I need to override this behavior

Thank's for helping

3 Replies

AG Ajith Govarthan Syncfusion Team April 24, 2020 01:19 PM UTC

Hi Ola, 

Greetings from Syncfusion. 

Based on your requirement we have prepared sample and in that sample we have removed default enter key behavior using the keyConfigs of the grid. 

In this sample we binded keyup event for the grid and when the enter key pressed we have edited the current focused row and the same can be saved if it is in edit state. We have attached the sample for your reference so please refer the sample for your reference. 

Code Snippet:  
app.component.ts 

dataBound(args){ 
(this.grid as any).keyConfigs.enter = "";                                 // remove the default enter key behavior 

public keyHandler(e){ 
if(e.keyCode === 13){ 
let rowElement = (e.target as HTMLElement).closest('.e-row'); 
if(rowElement){ 
let index =  parseInt(rowElement.getAttribute('aria-rowindex')); 
if(!this.grid.isEdit){                                                          
this.grid.selectRow(index); 
this.grid.startEdit(); 
} else { 
this.grid.endEdit(); 



Please get back to us if you need further assistance. 

Regards, 
Ajith G. 



BG Benjamim Goulart Bessa April 25, 2020 01:46 AM UTC

Ajith

Thank you, works like magic :D



PK Prasanna Kumar Viswanathan Syncfusion Team April 27, 2020 04:36 AM UTC

Hi Benjamin, 
 
We are happy to hear that the provided solution has been working fine at your end. 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon