Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 剑道格网总数';ajax获取后无法绑定_Jquery_Ajax_Kendo Grid_Kendo Asp.net Mvc_Kendo Datasource - Fatal编程技术网

Jquery 剑道格网总数';ajax获取后无法绑定

Jquery 剑道格网总数';ajax获取后无法绑定,jquery,ajax,kendo-grid,kendo-asp.net-mvc,kendo-datasource,Jquery,Ajax,Kendo Grid,Kendo Asp.net Mvc,Kendo Datasource,我有剑道网格,最初加载这些数据 @(Html.Kendo().Grid<GridModel>() .Name("Grid") .Columns(columns => { columns.Bound(p => p.ID).Hidden(true); columns.Bound(p => p.Name);

我有剑道网格,最初加载这些数据

 @(Html.Kendo().Grid<GridModel>()
              .Name("Grid")
              .Columns(columns =>
              {
                  columns.Bound(p => p.ID).Hidden(true);
                  columns.Bound(p => p.Name);
                  columns.Bound(p => p.Village);
                  columns.Command(command =>
                  {
                      command.Custom("ButtonP");
                      command.Custom("ButtonEdit");
                      command.Custom("ButtonActive");
                      command.Custom("ButtonPause");
                  }).Width("20%").HtmlAttributes(new { @class = "Custom" });
              })
              .Reorderable(reordering => reordering.Columns(true))
              .HtmlAttributes(new { style = "margin-bottom: 20px;" })
              .Sortable()
              .EnableCustomBinding(true)
              .ColumnMenu()
        .AutoBind(false)
              .Pageable(pageable => pageable
                  .Refresh(true)
                  .PageSizes(true)
                  .ButtonCount(5))
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .Read(read => read.Action("GetData", "Home"))
                 // .PageSize(30)
                  .ServerOperation(true)
             )
              .Events(e => e.DataBound("ModifyButtons"))
              )
和后端

var searchItems = Service.Search(SearchModel).Select(GridModel);
                return Json(searchItems, JsonRequestBehavior.AllowGet);
var searchItems = Service.Search(SearchModel).Select(GridModel);
                 var records = new 
                {
                    Data = searchItems,
                    Total = 90
                };
                return Json(records, JsonRequestBehavior.AllowGet);
但是我想做服务器分页,当我返回这个时(不工作的Ajax)

和后端

var searchItems = Service.Search(SearchModel).Select(GridModel);
                return Json(searchItems, JsonRequestBehavior.AllowGet);
var searchItems = Service.Search(SearchModel).Select(GridModel);
                 var records = new 
                {
                    Data = searchItems,
                    Total = 90
                };
                return Json(records, JsonRequestBehavior.AllowGet);
==要测试的硬编码总数。SearchModel包含用于复杂搜索的参数


请告诉我如何从服务器端找到总数,它只是将当前页面大小显示为总数。

如果您使用包装器,那么这可能是一个更简单的解决方案

如果您正在执行服务器端操作,则将控制器签名更改为类似于此的内容。注意:我假设它没有如下设置:

public JsonResult GetData([DataSourceRequest] DataSourceRequest request, SearchModel mySearchObject){
 //stuff happens here. 
 //get some results.
var model = someresults; 
//more stuff happens here....

return Json(model.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);


}
确保已添加以下用法,以使其正常工作:

using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
然后,这将为您返回一个新的
数据源
对象,因此网格应该正确绑定,并为您提供所需的总数、数据等

在没有看到更多您正在做的事情的情况下,这是假设了许多事情,但希望能让您第一眼看到代码中缺少的部分