javascript - 如何获得 Kendo 组页脚模板名称的自定义名称?

标签 javascript c# asp.net-mvc kendo-grid kendo-asp.net-mvc

我有以下 KendoGrid 代码:

<div class="grid-scrollable">
            <div>
                @(Html.Kendo().Grid<ViewModels.Payment.BhFormExpenseRRViewModel>()
                .Name("BHFormPATHRRGrid")
                .Events(e => e.DataBound("dataBoundpath"))
                .Events(e => e.Save("onBhFormpathModelGridSave"))
                .Events(e => e.Edit("onBhFormpathModelGridEdit"))
                .Columns(columns =>
                {
                    columns.Bound(p => p.Id).Hidden(true);
                    columns.Bound(p => p.ECId).Hidden(true);
                    columns.Bound(p => p.ExpenseCategory).ClientFooterTemplate("Total Billing Submitted")
                    .ClientGroupFooterTemplate("Total Expenses").EditorTemplateName("Decimal").Format("{0:c}");                 

                    columns.Group(g => g.Title("Current Month Expenses")
                        .Columns(a =>
                    {
                        a.Bound(c => c.ThisMonthPath).EditorTemplateName("Decimal").Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                        a.Bound(c => c.ThisMonthMatch).EditorTemplateName("Decimal").Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");

                    }));

                    columns.Group(g => g.Title("Reduced Monthly Expenses")
                        .Columns(a =>
                    {
                        a.Bound(c => c.ReduceExpensesBy).EditorTemplateName("Decimal").Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                        .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");

                        a.Bound(c => c.CurrentMonthExpensesSubmitted).EditorTemplateName("Decimal").Title("AdjustedPathAmount").Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                        .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                    }));

                    columns.Group(g => g.Title("Prior Month Expenses")
                        .Columns(a =>
                    {
                        a.Bound(c => c.PriorMonthMatch).Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                        a.Bound(c => c.PriorMonthPath).Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                    }));
                    columns.Group(g => g.Title("Cumulative Expenses YTD")
                        .Columns(a =>
                    {
                        a.Bound(c => c.YtdMonthMatch).Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                        a.Bound(c => c.YtdMonthPath).Format("{0:c}").ClientFooterTemplate("#=kendo.toString(sum,'C')#")
                    .ClientGroupFooterTemplate("#=kendo.toString(sum,'C')#");
                    }));
                    columns.Command(command =>
                    {
                        command.Edit().HtmlAttributes(new { @class = "btn-primary k-grid-edit" });
                    }).Width(200);
                })
                .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
                .Pageable(pageable => pageable.Refresh(true).PageSizes(true).ButtonCount(5))
                .Sortable()
                .Filterable(f => f.Operators(o => o.ForString(s => s.Clear()
                    .Contains("Contains")
                    .DoesNotContain("Does not contain")
                    .IsEqualTo("Is equal to")
                    .IsNotEqualTo("Is not equal to")
                    .StartsWith("Starts with")
                    .EndsWith("Ends with "))))
                .Selectable()
                .Resizable(resize => resize.Columns(true))

                .DataSource(dataSource => dataSource.Ajax().PageSize(20).Model(model => model.Id(p => p.ECId)).Model(model => model.Field(p => p.TotalProirExpensesBilled).Editable(false)).Model(model => model.Field(p => p.CurrentMonthExpensesSubmitted).Editable(false)).Model(model => model.Field(p => p.TotalExpensesYtd).Editable(false)).Model(model => model.Field(p => p.ExpenseCategory).Editable(false))
                .Model(model => model.Field(p => p.PriorMonthMatch).Editable(false)).Model(model => model.Field(p => p.PriorMonthPath).Editable(false)).Model(model => model.Field(p => p.YtdMonthMatch).Editable(false)).Model(model => model.Field(p => p.YtdMonthPath).Editable(false))
                .Aggregates(aggregates =>
                {

                    aggregates.Add(p => p.ThisMonthMatch).Sum();
                    aggregates.Add(p => p.ThisMonthPath).Sum();
                    aggregates.Add(p => p.PriorMonthMatch).Sum();
                    aggregates.Add(p => p.PriorMonthPath).Sum();
                    aggregates.Add(p => p.YtdMonthMatch).Sum();
                    aggregates.Add(p => p.YtdMonthPath).Sum();
                    aggregates.Add(p => p.ReduceExpensesBy).Sum();
                    aggregates.Add(p => p.CurrentMonthExpensesSubmitted).Sum();
                })

                .Update(update => update.Action("EditBHFormRR", "ReimbursementRequestProvider").Data("additionalInfoPath"))
                .Events(events => events.Error("errorpath"))
                .Group(groups => groups.Add(p => p.ExpenseTypeId))
                .Read(read => read.Action("BHFromExpenseGridRead", "ReimbursementRequestProvider", new { bhFormName = Model.BHFormsName, reimbursementEbsId = Model.ReimbursementEbsId, prrId = Model.PrrId, rrState = @ViewBag.RRStateRequest, serviceMonth = Model.ServiceMonth }))
                )
                )
            </div>
        </div>

我已将组页脚名称定义为:

.ClientGroupFooterTemplate("Total Expenses")

但我想用不同的页脚名称来命名每个不同的组。

有人可以帮助我实现这一目标吗? 我的结果应该是这样的:

  1. 第 1 组的页脚名称 = abc
  2. 第 2 组的页脚名称 = def

最佳答案

我不太明白最终目标是什么。您想要一个聚合值的页脚并为每个组添加一个页脚吗?我不确定从剑道论坛上看到的情况是否可行。如果它可以帮助您的情况,以便您可以展示类似的内容,您可以使用以下三个示例

1.

              columns.Group(g => g.Title("Current Month Expenses")
              .Columns(a =>
              {
                  a.Bound(c => c.Value).Width(200)
                      .ClientFooterTemplate("abs<div class = text-center>abc #=kendo.toString(sum,'C')#</div>");
                  a.Bound(c => c.ValueAdvance).Width(200)
                      .ClientFooterTemplate("def<div class = text-center>#=kendo.toString(sum,'C')#</div>");
              }));

Type of Group Title

2.

              columns.Group(g => g.Title("Current Month Expenses")
              .Columns(a =>
              {
                  a.Bound(c => c.Value).Width(200)
                      .ClientFooterTemplate("<div>abs</div><hr><div class = text-center>abc #=kendo.toString(sum,'C')#</div>");
                  a.Bound(c => c.ValueAdvance).Width(200)
                      .ClientFooterTemplate("<div>&nbsp;</div><hr><div class = text-center>#=kendo.toString(sum,'C')#</div>");
              }));

enter image description here

3.

              columns.Group(g => g.Title("Current Month Expenses")
              .Columns(a =>
              {
                  a.Bound(c => c.Value).Width(200)
                      .ClientFooterTemplate("<div class=text-center>abs</div><div class = text-center>abc #=kendo.toString(sum,'C')#</div>");
                  a.Bound(c => c.ValueAdvance).Width(200)
                      .ClientFooterTemplate("<div class=text-center>abs</div><div class = text-center>#=kendo.toString(sum,'C')#</div>");
              }));

enter image description here

第二种情况可能看起来更接近您想要的,我知道这不是最好的解决方案,但是如果没有更好的解决方案,我希望它能有所帮助。

关于javascript - 如何获得 Kendo 组页脚模板名称的自定义名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39398081/

相关文章:

c# - SQLite 删除列

c# - 如何在 emgucv c# 上实现非锐化 mask

c# - Redis 在 .net MVC 中压缩字符串值

javascript - 是否可以知道我的访客是否登录了 Facebook?

javascript - Jquery ui 如何选择那些启用的选项卡?

javascript - 针对大型网格优化 Three.js

asp.net-mvc - 部署到 azure 时图形丢失

javascript - 在 Javascript webresource CRM 中传递统一服务台上下文参数值

c# - 使用 XMLHTTPRequest header

jquery - 在 JQuery 中获取本地化语言