所以我使用Kendo Grid获得了以下一段代码服务器端。但是,我对下一步感到困惑。
如何将网格设置为最初按Income_Party分组?是否可以按每个分组添加总量?
@(Html.Kendo().Grid(Model.IncomeView)
.Name("grid")
.Columns(columns =>
{
columns.Bound(model => model.INC_INCOME_DESCRIPTION);
columns.Bound(item => item.INC_INCOME_AMOUNT);
columns.Bound(item => item.INC_INCOME_PARTY);
columns.Template(@<text>
@Html.ActionLink("Edit", "Edit", "MyLink" + item.VIEW_TYPE, new { id = item.GID, ReturnAction = "IncomeAndExpenses" }, null)
</text>)
.ClientTemplate("<a href='/brunch/statistics/brunchid=#= BrunchCode#'>#=BrunchCode#</a>")
.Title("");
})
)
答案 0 :(得分:4)
您可以像这样设置初始组和聚合:
@(Html.Kendo().Grid(Model.IncomeView)
.Name("grid")
.Columns(columns =>
{
columns.Bound(model => model.INC_INCOME_DESCRIPTION);
columns.Bound(item => item.INC_INCOME_AMOUNT).GroupFooterTemplate(@<text>
Total: @item.Sum
</text>);
columns.Bound(item => item.INC_INCOME_PARTY);
columns.Template(@<text>
@Html.ActionLink("Edit", "Edit", "MyLink" + item.VIEW_TYPE, new { id = item.GID, ReturnAction = "IncomeAndExpenses" }, null)
</text>)
.ClientTemplate("<a href='/brunch/statistics/brunchid=#= BrunchCode#'>#=BrunchCode#</a>")
.Title("");
})
.DataSource(dataSource => dataSource
.Server()
.Aggregates(aggregates =>
{
aggregates.Add(p => p.INC_INCOME_AMOUNT).Sum();
})
.Group(groups => groups.Add(p => p.INC_INCOME_PARTY))
)