在Kendo-grid中我必须管理输入键事件。如果用户在单元格内按Enter键,则必须将单元格焦点移动到给定的单元格索引并将其置于editabale模式。对于文本框我已经完成了部分但是对于Kendo Dropdown它只关注但不改变编辑模式。 我的代码是
edit: function (e) {
var sender = e.sender;
var cellToEdit = sender.content.find("td:eq(0)");
var input = e.container.find(".k-input");
var td = input.closest("td");
var rowIndex = td.parent().index();
var cellIndex = td.index();
input.on("keydown", function (event) {
if (event.keyCode == 13) {
debugger;//Check the current cell index
if (cellIndex == 2) {
debugger;
cellIndex = 3;//wanted to focus cell index next
var cellCloseT = $('#grid').data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent());
$('#grid').data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin(cellCloseT));
return false;
}
else if (cellIndex == 4) {
debugger;
cellIndex = 5;
var cellCloseT = $('#grid').data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent());
$('#grid').data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin(cellCloseT).editCell($(".k-grid-content")));
sender.editCell(cellToEdit);
return false;
}
else if (cellIndex == 6) {
debugger;
cellIndex = 7;
var cellCloseT = $('#grid').data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent());
$('#grid').data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin(cellCloseT));
return false;
}
else if (cellIndex == 8) {
debugger;
cellIndex = 8;
var cellCloseT = $('#grid').data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent());
$('#grid').data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin(cellCloseT));
return false;
} else if (cellIndex == 9) {
debugger;
cellIndex = 9;
var cellCloseT = $('#grid').data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent());
$('#grid').data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin(cellCloseT));
return false;
}
//else if (cellIndex == 11 || cellIndex == 12) {
// CreateNewGridRow();
// var grid = $("#grid").data("kendoGrid");
// //grid.dataSource.read();
// var count = grid.dataSource.total();
// setRow(count, e.model);
// balance();
// }
}
//else if (event.keyCode == 13) {
// if (cellIndex == 11 || cellIndex == 12) {
// CreateNewGridRow();
// var grid = $("#grid").data("kendoGrid");
// //grid.dataSource.read();
// var count = grid.dataSource.total();
// setRow(count, e.model);
// balance();
// }
//}
})
}