kendo UI中gird在修改里面内容时回车到下一个方格
时间: 2024-05-11 08:15:56 浏览: 136
您可以试试按下Tab键,它会让光标移动到下一个单元格。如果您想自定义这个行为,您可以使用edit event的edit方法,并设置nextCellOnEnter选项。例如:
```
edit: function(e) {
e.container.find("input").on("keydown", function(event) {
if (event.keyCode === kendo.keys.ENTER) {
event.preventDefault();
var nextCell = this.parentNode.nextSibling;
if (nextCell) {
var nextInput = nextCell.querySelector("input");
if (nextInput) {
nextInput.focus();
}
}
}
});
}
```
相关问题
kendo UI中gird回车到下一个方格
您可以使用Kendo UI Grid的内置编辑器并在其上注入自定义事件来处理回车键。首先,您需要在Grid的column定义中指定'editor'选项。然后,您可以使用keydown事件来拦截回车键并将焦点移动到下一个单元格。以下是一个基本示例:
```javascript
$("#grid").kendoGrid({
dataSource: {
data: [
{ id: 1, name: "John", age: 25 },
{ id: 2, name: "Jane", age: 30 }
],
schema: {
model: {
id: "id",
fields: {
name: { type: "string" },
age: { type: "number" }
}
}
}
},
columns: [
{ field: "name", title: "Name", width: "120px", editor: customEditor },
{ field: "age", title: "Age", width: "80px", editor: customEditor }
],
editable: "inline"
});
function customEditor(container, options) {
var input = $("<input/>");
input.attr("name", options.field);
input.appendTo(container);
// bind the keydown event
input.on("keydown", function(e) {
// check if the key pressed is the enter key
if (e.keyCode === 13) {
e.preventDefault();
// find the next input field and focus it
$(this).closest(".k-grid-edit-row")
.next(".k-grid-edit-row")
.find("input[name='" + options.field + "']")
.focus();
}
});
}
```
阅读全文