This seems to work for me although Chrome and Firefox don't seem to scroll the grid to show the latest row when using virtual scrolling. IE10 on the other hand does work.
var ps_Fn = function () {
var rIndex = 0,
cIndex = 0,
FOCUSED = "k-state-focused";
return {
grid_key: function (gridId, AfterNewRow) {
var grid = $(gridId).getKendoGrid();
$(gridId).on('keydown', function (e) {
if (e.keyCode == 9 || e.keyCode == 38 || e.keyCode == 40) {
var curRow = grid.select();
if (!curRow.length)
return;
var cell = grid.current()[0],
newRow,
model = grid._modelForContainer(cell),
field = grid.columns[cIndex].field;
cIndex = cell.cellIndex;
if (e.keyCode == 9) {
if (e.shiftKey) {
if (cIndex == curRow[0].cells.length -1) {
newRow = curRow.prev();
}
else
return;
}
else {
if (cIndex != 0)
return;
newRow = curRow.next();
}
}
else if (grid._editContainer && model.editable(field)) { //in edit mode don't want to muck around with combos, etc.
return;
}
else if (e.keyCode == 38) {
newRow = curRow.prev();
while (newRow && newRow.length && newRow[0].cells.length != curRow[0].cells.length) { //take care of grouping
newRow = newRow.prev();
}
}
else if (e.keyCode == 40) {
newRow = curRow.next();
while (newRow && newRow.length && newRow[0].cells.length != curRow[0].cells.length) { //take care of grouping
newRow = newRow.next();
}
}
if (!newRow.length)
return;
rIndex = newRow[0].rowIndex,
ps_Fn.grid_setcurrent(grid, AfterNewRow);
}
});
},
grid_savecurrent: function(grid) {
var curRow = grid.select();
if (!curRow.length)
return;
var cell = grid.current()[0];
cIndex = cell.cellIndex,
rIndex = curRow[0].rowIndex;
},
grid_setcurrent: function (grid, AfterNewRow) {
var curRow = grid.tbody.find(">tr:eq(" + rIndex + ")");
grid.select(curRow);
var newCell = curRow.find(">td:eq(" + cIndex + ")");
if (grid._editContainer) {
grid.closeCell();
}
if (AfterNewRow) {
var dataItem = grid.dataItem(curRow);
if (dataItem)
AfterNewRow(dataItem);
}
grid.current(newCell);
newCell.focus();
newCell.addClass(FOCUSED);
};
}();
var ps_Fn = function () {
var rIndex = 0,
cIndex = 0,
FOCUSED = "k-state-focused";
return {
grid_key: function (gridId, AfterNewRow) {
var grid = $(gridId).getKendoGrid();
$(gridId).on('keydown', function (e) {
if (e.keyCode == 9 || e.keyCode == 38 || e.keyCode == 40) {
var curRow = grid.select();
if (!curRow.length)
return;
var cell = grid.current()[0],
newRow,
model = grid._modelForContainer(cell),
field = grid.columns[cIndex].field;
cIndex = cell.cellIndex;
if (e.keyCode == 9) {
if (e.shiftKey) {
if (cIndex == curRow[0].cells.length -1) {
newRow = curRow.prev();
}
else
return;
}
else {
if (cIndex != 0)
return;
newRow = curRow.next();
}
}
else if (grid._editContainer && model.editable(field)) { //in edit mode don't want to muck around with combos, etc.
return;
}
else if (e.keyCode == 38) {
newRow = curRow.prev();
while (newRow && newRow.length && newRow[0].cells.length != curRow[0].cells.length) { //take care of grouping
newRow = newRow.prev();
}
}
else if (e.keyCode == 40) {
newRow = curRow.next();
while (newRow && newRow.length && newRow[0].cells.length != curRow[0].cells.length) { //take care of grouping
newRow = newRow.next();
}
}
if (!newRow.length)
return;
rIndex = newRow[0].rowIndex,
ps_Fn.grid_setcurrent(grid, AfterNewRow);
}
});
},
grid_savecurrent: function(grid) {
var curRow = grid.select();
if (!curRow.length)
return;
var cell = grid.current()[0];
cIndex = cell.cellIndex,
rIndex = curRow[0].rowIndex;
},
grid_setcurrent: function (grid, AfterNewRow) {
var curRow = grid.tbody.find(">tr:eq(" + rIndex + ")");
grid.select(curRow);
var newCell = curRow.find(">td:eq(" + cIndex + ")");
if (grid._editContainer) {
grid.closeCell();
}
if (AfterNewRow) {
var dataItem = grid.dataItem(curRow);
if (dataItem)
AfterNewRow(dataItem);
}
grid.current(newCell);
newCell.focus();
newCell.addClass(FOCUSED);
};
}();