[英]Posting a model with Kendo Grid read action
I'm trying to add a search form to my page that updates the Kendo Grid. 我正在尝试向我的页面添加搜索表单以更新Kendo Grid。 How should I send the Ajax call, so the ASP.NET MVC Model Binder be able to work?
我应该如何发送Ajax调用,以便ASP.NET MVC Model Binder能够正常工作?
This is my Ajax call: 这是我的Ajax电话:
var grid = $("#SearchSheetHeads").data('kendoGrid');
var data = $("#SearchSheet").serialize();
grid.dataSource.transport.options.read.url = "@Url.Action("SearchHeaderRead", "Sheet")";
grid.dataSource.transport.options.read.data = data;
grid.dataSource.transport.options.read.dataType = 'json';
grid.dataSource.transport.options.read.contentType = "application/json";
grid.dataSource.transport.options.read.type = "POST";
grid.dataSource.fetch();
I've also tried it by stringify
method and removing contentType
. 我也通过
stringify
方法并删除contentType
尝试。
And this is my Action signature: 这是我的动作签名:
public ActionResult SearchHeaderRead([DataSourceRequest] DataSourceRequest request, SearchSheetHeaderViewModel model)
And the request looks like this: 请求看起来像这样:
Can't test it at the moment, but try something like this: 目前无法对其进行测试,但可以尝试以下操作:
var grid = $("#SearchSheetHeads").data('kendoGrid');
var data = $("#SearchSheet").serialize();
$.ajax(
{
type: 'POST',
url: '@Url.Action("SearchHeaderRead", "Sheet")',
dataType: 'json',
data: { model: data },
success: function (result) {
grid.dataSource.data(result.Data);
}
});
data: { model: data }
is probably the important part for you. data: { model: data }
对您来说可能是重要的部分。
您可以按照下面的说明更改第二行并尝试一下吗
var data = $("#SearchSheetHeads").data('kendoGrid').dataSource.data();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.