【发布时间】:2014-02-17 09:31:15
【问题描述】:
我正在使用 JavaScript 中的内联可编辑选项开发 KendoUI 网格,并且无法使更新按钮触发单击事件并将数据发布到服务器端更新事件。单击更新按钮甚至不会更新客户端上的网格。
希望有人能帮我指出我在这里做错了什么。
这不是重复的,因为我已经厌倦了答案中的 jfiddle 链接并且它也不起作用。 kendo UI grid update function wont fire
<div id="grid"></div>
@section Scripts{
<script type="text/javascript">
$(function () {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "Home/GetPupilsAsJson",
dataType: 'json'
},
update: {
url: "Home/UpdatePupils",
dataType: 'json',
type: 'POST'
}
},
pageSize: 5,
autoSync: true
});
$('#grid').kendoGrid({
dataSource: dataSource,
editable: "inline",
pageable: true,
columns: [{
field: "Id",
title: "Id",
width: 150,
hidden: true
}, {
field: "Firstname",
title: "Firstname",
width: 150
}, {
field: "Lastname",
title: "Lastname",
width: 150
}, {
field: "DateOfBirth",
title: "DateOfBirth",
width: 150
}, {
field: "Class",
title: "Class",
width: 150
}, {
field: "Year",
title: "Year",
width: 150
},
{
command: ["edit"],
width: 150
}]
});
});
</script>
}
家庭控制器
public ActionResult GetPupilsAsJson()
{
return Json(GetPupils(), JsonRequestBehavior.AllowGet);
}
[AcceptVerbs(HttpVerbs.Post)]
[HttpPost]
public void UpdatePupils(Pupil p)
{
//never reach here
}
【问题讨论】:
-
您能否在 UpdatePupils 中尝试不使用参数 'Pupil p' 并告诉我程序是否到达那里?
-
@MustafaP .. 按照你的建议,我很累,但仍然无法正常工作。事实上,我的问题是更新按钮甚至没有关闭客户端上的编辑字段。我尝试使用 MVC 包装器,它工作正常,但不幸的是我们没有包装器的许可证。
-
如果您的浏览器位于
Developer Mode或inspection并检查网络流量,您是否看到任何请求,您看到请求通过了吗?我的意思是,您的浏览器是否在调用Home/UpdatePupils? -
@OnaBai 没有来自 Kendo 的请求。
标签: asp.net-mvc kendo-ui kendo-grid