Author Topic: Restrict tab out to next cell if it is the last cell in row  (Read 2576 times)

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Restrict tab out to next cell if it is the last cell in row
« on: December 08, 2017, 07:15:42 pm »
Hi Team,

We want to customize the tab functionality in such a way that when it reaches to the last cell in the row, next tab should not focus to the first cell in the next row. Similarly for shift+tab ,if it is first cell in row, it should not go to the end of the previous row.

See the attached snapshot.

we are in the last cell of third row. Now if i press tab key, the focus will move to the first cell in the next row(Sno in this case). We want to restrict this behavior in our grids.

Please suggest ASAP

« Last Edit: December 08, 2017, 07:17:54 pm by cijojohn »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Restrict tab out to next cell if it is the last cell in row
« Reply #1 on: December 11, 2017, 11:44:49 am »
Please add this to the initialization object of grid.

Code: [Select]
beforeCellKeyDown: function(evt, ui){
var keyCode = evt.keyCode,
KC = $.ui.keyCode;
if(ui.colIndx==this.getColModel().length-1){
if( (keyCode == KC.TAB && !evt.shiftKey) || keyCode == KC.RIGHT)
return false;
}
else if(ui.colIndx == 0){
if( (keyCode == KC.TAB && evt.shiftKey ) || keyCode == KC.LEFT)
return false;
}
}

http://jsfiddle.net/qpjgfmvt/

cijojohn

  • Pro Ultimate
  • Jr. Member
  • *
  • Posts: 73
    • View Profile
Re: Restrict tab out to next cell if it is the last cell in row
« Reply #2 on: December 11, 2017, 01:03:59 pm »
can u suggest something similar for PQ 3.3 version? I think this event "beforeCellKeyDown" works for PQ version 4.

Thanks
« Last Edit: December 11, 2017, 02:10:24 pm by cijojohn »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Restrict tab out to next cell if it is the last cell in row
« Reply #3 on: December 11, 2017, 11:07:26 pm »
use cellKeyDown instead of beforeCellKeyDown in v3

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Restrict tab out to next cell if it is the last cell in row
« Reply #4 on: December 15, 2017, 06:12:48 pm »
In v5, this is the default behaviour of key navigation.