这是我的剑道网格代码。我的第一个问题是如果单击编辑,我可以编辑的名称字段:false不工作。它给了文本框。
我的第二个问题是,我想给年龄下降。我怎么能这样做?
$("#grid").kendoGrid({
columns: [
{ field: "id", hidden: true },
{ field: "name", title: "Name" },
{ field: "age", title: "Age" },
{ command: ["edit"] }
],
editable: "inline",
dataSource: [
{ id: "1", name: "Andrew", age: "30" },
{ id: "2", name: "Robert", age: "29" },
{ id: "3", name: "Frank", age: "35" }
],
schema: {
model: {
id: "id",
fields: {
id: { editable: false },
name: { editable: false },
age: { editable: true }
}
}
},
});
答案 0 :(得分:1)
以下是完整的代码示例。
var dataSource = new kendo.data.DataSource({
pageSize: 20,
data: [
{ id: "1", name: "Andrew", age: "30" },
{ id: "2", name: "Robert", age: "29" },
{ id: "3", name: "Frank", age: "35" }
],
autoSync: true,
schema: {
model: {
id: "id",
fields: {
id: { editable: false, nullable: true, type: "number" },
name: { editable: false },
age: {
validation: { min: 0, required: true },
editable: true,
nullable: true,
type: "number"
}
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
editable: "inline",
columns: [
{ field: "name",title: "Name" },
{ field: "age", title: "Age", width: "180px"},
{ command: ["edit"] }
]
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.318/js/kendo.all.min.js"></script>
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.common.min.css" rel="Stylesheet" />
<div id="grid"></div>