我正在尝试将 Kendo UI 网格与创建的 API 建模器绑定。我检查了 Web API 建模器,它以 json 格式返回数据,但是当我创建 html 页面以在 Kendo UI 网格中显示数据时,只显示网格并且没有项目。这是我的 html 代码。有人请指出哪里做错了。提前致谢。我现在停留在这 3 天。
</head>
<body>
<div id="example" class="k-content">
<div id="grid"></div>
<script type="text/javascript">
$(document).ready(function () {
var crudServiceBaseUrl = "Customer/Get";
//alert(crudServiceBaseUrl);
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "Customer/Get",
dataType: "jsonp"
}
},
batch: true,
pageSize: 20,
schema: {
model: {
id: "customerID",
fields: {
customerID: { editable: false, nullable: true },
customerName: { validation: { required: true} }
}
}
}
});
var test = dataSource.data.length;
//i tried debugging but data length is 1
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 430,
toolbar: ["create"],
columns: [
{ field: "customerID", title: "ID", width: "200px" },
{ field: "customerName", title: "Name", width: "200px" },
{ command: ["edit", "destroy"], title: " ", width: "172px"}],
editable: "inline"
});
});
</script>
</div>
</body>
</html>