kendo-grid - Kendo UI JQuery - 网格一键触发多个“读取”、“创建”、“更新”和“销毁”操作
问题描述
- 当我使用“kendo.data.GanttDataSource”时,网格会从控制器触发所有“读取”、“创建”、“更新”和“销毁”操作方法:但当我使用“kendo.data.DataSource”时,只有网格触发“读取”。
- 当我点击“添加新记录”按钮时,会触发一个相应的创建操作方法(成功)但也会触发多个失败的更新操作方法(这些触发的数量等于网格中的行数。内部服务器错误( 500)为每个调用返回)
- 当我点击删除时,会为所有记录触发删除操作方法,从而使我的网格为空。
<script>
$(document).ready(function () {
var datasource = new kendo.data.GanttDataSource({
type: "json",
transport: {
read: {
url: '@Url.Action("Details", "Student")',
//url: "/Student/Details",
dataType: "json",
type: "GET"
},
create: {
url: '@Url.Action("AddStudent", "Student")',
//url: "/Student/AddStudent",
dataType: "json",
type: "POST"
},
update: {
url: '@Url.Action("UpdateStudent", "Student")',
//url: "/Student/UpdateStudent",
dataType: "json",
type: "POST"
},
destroy: {
//url: '@Url.Action("DeleteStudent", "Student")',
url: "/Student/DeleteStudent",
dataType: "json",
type: "POST"
},
parametermap: function (options, operation) {
if (operation !== "read" && options.models) {
return { models: kendo.stringify(options.models) };
}
},
pageSize: 2,
schema: {
model: {
id: "rollno",
fields: {
rollno: { from: "rollno", type: "number" },
name: { from: "name", type: "string" },
address: { from: "address", type: "string" }
}
}
}
}
});
$("#stdGrid").kendoGrid({
dataSource: datasource,
columns: [
{
field: "rollno",
title: "Roll No."
},
{
field: "name",
title: "Name"
},
{
field: "address",
title: "Address"
},
{ command: [ "edit", "destroy"], titlt:" "}
],
toolbar: ["search", "create"],
//autobind: true,
autosync: false,
filterable: true,
sortable: true,
editable: "inline",
pageable: true,
save: function (e) {
setTimeout(function () {
//$("#stdGrid").data("kendoGrid").refresh();
$("#stdGrid").data("kendoGrid").dataSource.read();
}, 200);
}
});
});
</script>
<style type="text/css">
.k-grid-search {
margin-left: auto;
margin-right: 0;
}
</style>
解决方案
推荐阅读
- jenkins - 如何在 AWS 中创建到多个 Jenkins 服务器的基于路径的路由?
- java - Java Sound API 在播放后锁定音频文件
- java - 使用 Apache POI 将样式和编号应用于 word 文档
- javascript - 看似有效的表格行和表格数据未显示在表格正文中
- xamarin.forms - 如何构建 Xamarin.Forms UWP AM64 应用程序?
- eclipse - 是什么导致“鬼”类在发生重大变化后出现在 Tomcat/Eclipse 中?
- javascript - React Firebase Snapshot 检索所有子项
- php - PHP将日期转换为不同的格式
- javascript - 如何在 React 中获取特定映射文件的“名称”属性?
- python - 如何在 Databricks 中设置 python 测试