Asp.net mvc KendoUI MVC辅助网格分页

Asp.net mvc KendoUI MVC辅助网格分页,asp.net-mvc,kendo-grid,Asp.net Mvc,Kendo Grid,我正在使用Asp.Net KendoUI网格MVC帮助程序,但无法使分页正常工作。具体来说,我无法获得要显示的总记录。代码如下: @(Html.Kendo().Grid(Model.FunctionList.AsEnumerable()) .Name("Grid") .DataSource(dataSource => dataSource .Server() .Total(50) .Mo

我正在使用Asp.Net KendoUI网格MVC帮助程序,但无法使分页正常工作。具体来说,我无法获得要显示的总记录。代码如下:

@(Html.Kendo().Grid(Model.FunctionList.AsEnumerable())
        .Name("Grid")
        .DataSource(dataSource => dataSource
            .Server()
            .Total(50)
            .Model(model => model.Id(f => f.FunctionId))
            .Read(read => read.Action("Index", "Function"))
            .Update(update => update.Action("Edit", "Function"))
            .Destroy(destroy => destroy.Action("Delete", "Function"))
            )

  .Columns(columns =>
  {
      columns.Bound(f => f.FunctionName);
      columns.Bound(f => f.FunctionDescription);
      columns.Command(command => { command.Custom("Edit").Action("Edit", "Function").SendDataKeys(true); command.Destroy(); }).Width(200);

  })
.Scrollable()
.Groupable()
.Sortable()

.Pageable(pageable => pageable
                    .PageSizes(true)
                    .ButtonCount(5))

.Filterable(filterable => filterable
                    .Extra(false)
                    .Operators(ops => ops
                        .ForString(str => str.Clear()
                        .Contains("Contains")
                        .StartsWith("Starts with")
                        .EndsWith("Ends with")
                        .IsEqualTo("Equal to")
                        .IsNotEqualTo("Not Equal To")
                    )))    
    )
注意总数(50)。无论选择的页面大小(5、10或20),我只得到一个页面,即网格显示“n个项目中的1到n个”,其中n是页面大小。它应该显示“50个项目中的1-5个”,页面大小为5,总记录为50

生成的javascript(查看源代码)显示总数(50)没有影响:

"pageSize":5,"page":1,"total":5,"serverPaging":true
注意“总计”:5,其中应为“总计”:50

这是一个很好的分页教程

你需要做一个跳跃和采取

如果你的页面大小是10,而你的页码是2,你基本上要做这个总和

跳过。((第1页)*页面大小。接受(页面大小)

soo if将记录10-20 展示了其中的10个


这可能没有意义,但链接很好!:)

将kendogrid的服务器分页设置为false:

serverPaging: false, 

我张贴了整个网格,这是我的申请工作良好。但是我看了一下您的代码,您的数据源属性有问题,您缺少.Ajax().ServerOperation(false)(添加这两个属性后,我进行了分页),将其与我的进行比较,您会找到真正的原因

    Html.Kendo().Grid(Model.asdry).Name("abc").Columns(c =>
     {
c.Bound(p => p.datetimecalculated).Format("{0:dd-MM-yyyy}");
         c.Bound("").ClientTemplate("#= purchaseCriteria(data) #").Title("Sold/Bought");
         c.Bound(p => p.numcontracts);
         c.Bound(p => p.entityid);
         c.Bound(p => p.leagueid);
         c.Bound("")
             .ClientTemplate("#= setSeasonYear(data) #")
             .Sortable(false)
             .Title("Year");

         c.Bound("")
             .ClientTemplate("#= setSeason(data) #")
             .Sortable(false)
             .Title("Season");
         c.Bound(p => p.contractmeasurable);
         c.Bound(p => p.price).ClientTemplate("#= moneyformat_at(price) #");
         c.Bound(p => p.profitorloss).ClientTemplate("#= moneyFormat(profitorloss) #");

     }).DataSource(
    d => d
        .Ajax()
        .ServerOperation(false)

    )
    .Pageable()
    .Sortable()
    .Resizable(resizing => resizing.Columns(true))
            )
更新 使用这些的原因如下 .Ajax()//指定使用Ajax绑定 .ServerOperation(false)//分页、排序、筛选和分组将在客户端完成