KendoUI:在MVC4中使用HTML Helper添加网格聚合 [英] KendoUI: Adding Grid Aggregates with HTML Helper in MVC4
本文介绍了KendoUI:在MVC4中使用HTML Helper添加网格聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在网格的HTML帮助器中添加一个总计,但不确定在此示例中如何为总计"字段添加一个总计.这是我的简单示例:
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
:
@(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屋!
查看全文