KendoUI:在 MVC4 中使用 HTML Helper 添加网格聚合 [英] KendoUI: Adding Grid Aggregates with HTML Helper in MVC4

查看:18
本文介绍了KendoUI:在 MVC4 中使用 HTML Helper 添加网格聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 HTML 帮助器中为网格添加总和聚合,但不确定如何在此示例中为 Total 字段添加它.这是我的简单示例:

I am trying to add a sum aggregate in the HTML helper for the grid, but am not sure how to add it for the Total field in this example. This is my simple example:

   @(Html.Kendo().Grid(Model).Name("Grid") 
      .Pageable()
      .Sortable()
      .Scrollable()
      .Filterable()
      .Columns(columns =>
          {
              columns.Bound(p => p.FirstName);
              columns.Bound(p => p.LastName);
              columns.Bound(p => p.Email);
              columns.Bound(p => p.Total).ClientFooterTemplate("Sum: $#= sum #");
          })
      .DataSource(dataSource => dataSource
          .Ajax()
          .Read(read => read.Action("Users_Read", "Home"))

      ))

推荐答案

您没有在 DataSource 中定义 aggregate:

You are not defining the aggregate in the DataSource:

@(Html.Kendo().Grid(Model).Name("Grid") 
  .Columns(columns =>
      {
          columns.Bound(p => p.FirstName);
          columns.Bound(p => p.LastName);
          columns.Bound(p => p.Email);
          columns.Bound(p => p.Total).FooterTemplate("Sum: #= sum #");
      })
  .DataSource(dataSource => 
               dataSource.Ajax()
                         .Read(read => read.Action("Users_Read", "Home"));
                 .Aggregates(aggregates => { aggregates.Add(p => p.Total).Sum(); } )
                 .ServerOperation(false) 
  ))

这篇关于KendoUI:在 MVC4 中使用 HTML Helper 添加网格聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆