2014-02-18 67 views
2

我正在使用Asp.Net KendoUI网格MVC助手,但无法使分页正常工作。具体来说,我无法获得要显示的总记录。这是代码:KendoUI MVC Helper Grid Paging

@(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") 
        )))  
    ) 

请注意.Total(50)。不管选择的页面大小(5,10或20),我只得到1页,即网格显示“n到n个项目”,其中n是页面大小。应当表示“1 -5 50的项目”为5页大小和总记录50.

生成的JavaScript(查看源)示出了总的(50)没有任何影响:

"pageSize":5,"page":1,"total":5,"serverPaging":true 

通知 “总”:5,它应该是 “总”:50

回答

0

kendogrid集serverPaging为false:

serverPaging: false, 
1

我张贴这是工作在我的应用程序精细全格。但我犯了一个看你的代码有一个与你的数据源属性问题,你缺少阿贾克斯().ServerOperation(假)(我加入这两个后作出拼版作业),进行比较与我,你会发现真正的原因

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使用 .ServerOperation(假)结合//分页,排序,过滤和分组wi完成客户端