Author Topic: Do the left and right arrow keys work if the grid is on edit mode  (Read 992 times)

stancao

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Do the left and right arrow keys work if the grid is on edit mode
« on: September 17, 2021, 03:33:07 am »
Hi,
I want to know that, do the left and right arrow keys work if the grid cell is on edit mode just like up and down arrow keys can do?

Thank you!

Stan
« Last Edit: September 17, 2021, 03:54:27 am by stancao »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Do the left and right arrow keys work if the grid is on edit mode
« Reply #1 on: September 17, 2021, 08:45:50 am »
Hi Stan

There is no ready to use option for it, but it can be customized using editorKeyDown event:

https://paramquery.com/pro/api#event-editorKeyDown

e.g. on left key, select the previous cell by decrementing the colIndx of current cell and return false to prevent default behavior inside the editor.

Code: [Select]
editorKeyDown: function(evt, ui){
if(evt.originalEvent.keyCode == $.ui.keyCode.LEFT){
ui.colIndx--;
this.setSelection(ui);
return false;
}
},

TODO: you would also need to check boundary conditions, e.g. if its the first leftmost cell, then it can't move further left.

stancao

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Do the left and right arrow keys work if the grid is on edit mode
« Reply #2 on: September 17, 2021, 07:48:56 pm »
Thank you and they are working now! :)