I have a batch editing grid where the user can add a new row either by clicking the Add button or tabbing off of the last editable column. The Add button works as intended...it adds a new row at the bottom of the grid and puts the keyboard focus in the first column of the new row.
The problem I am having is calling addRow programatically. It creates the new row at the bottom of the grid, but it automatically puts the keyboard focus in the second column of the new row. I want it to behave the same way as pressing the Add button. Here is the script that catches my keypress [TAB], and determines if it is the last row and last column (in my case it's column index 6).
Any idea why my script is automatically moving it to the second column?
Thanks,
Jason
The problem I am having is calling addRow programatically. It creates the new row at the bottom of the grid, but it automatically puts the keyboard focus in the second column of the new row. I want it to behave the same way as pressing the Add button. Here is the script that catches my keypress [TAB], and determines if it is the last row and last column (in my case it's column index 6).
function
onDataBound(e) {
var
grid = $(
"#VINGrid"
).data(
"kendoGrid"
);
$(grid.tbody).on(
"keydown"
,
"td"
,
function
(e) {
if
(e.keyCode == 9)
{
var
row = $(
this
).closest(
"tr"
);
var
rowIdx = $(
"tr"
, grid.tbody).index(row);
var
colIdx = $(
"td"
, row).index(
this
);
var
count = grid.dataSource.total();
if
(rowIdx == count-1 && colIdx == 6)
{
grid.addRow();
}
}
});
}
Any idea why my script is automatically moving it to the second column?
Thanks,
Jason