以下代码是Kendo文档
中内置命令示例的扩展版本<!DOCTYPE html5>
<html>
<head>
<title>Untitled Page</title>
<link href="styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/kendo.web.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ command: ["edit", "destroy"]} // displays the built-in "edit" and "destroy" commands
],
editable: "inline",
dataSource: new kendo.data.DataSource ({
data: [{ name: "Jane Doe" }, { name: "Joe Soap" }, { name: "Fred Blogs"}]
})
});
});
</script>
</head>
<body>
<div id="grid"></div>
</body>
</html>
点击任何“编辑”按钮都可以正常工作。如果现在单击另一个“编辑”按钮而不取消第一个,则原始编辑行将被取消,但现在所有编辑按钮都无法在编辑模式下打开一行。当网格使用远程数据源时,不会演示此行为。
Kendo知道这个问题吗?
有没有人知道解决方法?
答案 0 :(得分:4)
当模型中没有定义id
时,这是一个常见问题(它实际上不是Kendo UI的问题,可能不是一个明确记录的行为)。
改为使用此grid
定义:
$("#grid").kendoGrid({
columns : [
{ field: "name" },
{ command: ["edit", "destroy"]} // displays the built-in "edit" and "destroy" commands
],
editable : "inline",
dataSource: new kendo.data.DataSource({
data : [
{ id: 1, name: "Jane Doe" },
{ id: 1, name: "Joe Soap" },
{ id: 2, name: "Fred Blogs"}
],
schema: {
model: {
id: "id"
}
}
})
});
我在每行添加了id
字段,然后我定义schema.model.id
为id
。看到它正在运行here