We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to move the cursor to the next cell when enter key is pressed

Hi,

I have a requirement to move the cursor to the next cell in the right hand side when the enter key is pressed. Is there a way to do it in the grid batch edit mode?


Thank you and best regards,

Kalum


2 Replies

PS Pavithra Subramaniyam Syncfusion Team December 30, 2022 05:58 AM UTC

Hi kalum,


Thanks for contacting Syncfusion support.


You can achieve your requirement by canceling the default Enter action inside the “keyPressed” event and editing the next cell using “editCell” method. Please refer to the below code example and API link for more information.


function keyPressed(args) {

  if (args.key == 'Enter' && grid.isEdit) {

    var td = ej.grids.parentsUntil(args.target, 'e-rowcell');

    var index = parseInt(td.getAttribute('data-colindex'));

    var curRowIndex = parseInt(td.getAttribute('index'));

    var col = grid.getColumns()[index + 1];

    if (col) {

      args.cancel = true;

      grid.editModule.editModule.editCell(curRowIndex, col.field, true);

    }

  }

}

 


https://ej2.syncfusion.com/javascript/documentation/api/grid/#keypressed

https://ej2.syncfusion.com/javascript/documentation/api/grid/edit/#editcell


Regards,

Pavithra S



WI will January 6, 2023 08:32 AM UTC

In the Options window select Advanced. Under the Editing options uncheck the After pressing Enter, move the selection box if you want the active cell cursor not to move after pressing enter. Select a direction if you want the active cell cursor to move a direction other than Down after pressing enter.


Regards,

Will


Loader.
Up arrow icon