簡體   English   中英

Kendo UI網格聚合使用組和Razor語法獲取'sum'是未定義的錯誤

[英]Kendo UI grid aggregate using groups and Razor syntax getting 'sum' is undefined error

我有一個telerik父網格,在下面有聚合網格作為子網格,這是我的代碼, 這里是父網格-

@(Html.Kendo().Grid<ClaimListbyCompanyUserId1_Result>()
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(e => e.chkbox)
                .HeaderTemplate("<input type='checkbox' id='chkAllClaim' class='chkAll'/>")
                .ClientTemplate("<input type='checkbox' class='clsClaim'/>")
                .HtmlAttributes(new { style = "text-align: center" })
                .HeaderHtmlAttributes(new { style = "text-align: center" })
                .Filterable(false)
                .Sortable(false)
                .Groupable(false)
                .Width(50);
            columns.Bound(e => e.Name)
                //.Filterable(filterable => filterable.UI("claimType"))
                .Title(@objFieldNameList["Name"])
                .Width(80);
            columns.Bound(e => e.Description)
                .Width(120)
                .Title(@objFieldNameList["Description"]);
            columns.Bound(e => e.Amount).Template(@<text></text>).ClientTemplate(@clsExtensions.ToCurrencyFormat(Convert.ToString("#=decimalAmount#"), ProjectSession.CurrencySign, ProjectSession.CurrencyCode_ISO3, ProjectSession.CurrencyFormat, ProjectSession.DisplayPlaceCurrencyFormat))
                .Width(100).Title(@objFieldNameList["Amount"]);
            columns.Bound(e => e.PayableAmount).Template(@<text></text>).ClientTemplate(@clsExtensions.ToCurrencyFormat(Convert.ToString("#=decimalAmount#"), ProjectSession.CurrencySign, ProjectSession.CurrencyCode_ISO3, ProjectSession.CurrencyFormat, ProjectSession.DisplayPlaceCurrencyFormat))
                .Width(100).Title(@objFieldNameList["Payable Amount"]);
            columns.Bound(e => e.Status).Filterable(filterable => filterable.UI("status")).ClientTemplate("#=GetStatus(Status)#").Width(100).Title(@objFieldNameList["Status"]);
            columns.Bound(e => e.DATE).Format("{0:" + ProjectSession.DateFormat + "}")
                    .Title(@objFieldNameList["Last Modified"])
                    .Width(130);
            columns.Bound(e => e.TotalApprovals)
        .Width(120)
        .Title(@objFieldNameList["Approvals"]);

            columns.Template(@<text></text>).ClientTemplate(
        @Html.ViewLink("View Comment", "javascript:", null, null, new { datahref = Url.Action("_ViewClaimComment", "Home", new { Data = "#=ClaimId#" }), @class = "clsView" }).ToHtmlString())
        .Title(@objFieldNameList["Comment"])
        .Width(60);

            columns.Template(@<text></text>).ClientTemplate(
        @Html.EditLink("Edit", "ExpenseGroupDetails", "ExpenseGroup1", new { Data = "#=ClaimId#" }) + "&nbsp;" +
        @Html.DeleteLink("Delete", "javascript:", null, null, new { Data = "#=ClaimId#", @class = "clsDelete", @datahref = Url.Action("Delete", "ExpenseGroup1") }) + "&nbsp;" +
        @Html.PrintLink("Receipt", "DownloadClaimReport", "ExpenseGroup1", new { Data = "#=ClaimId#" }))
        .Title(@objFieldNameList["Action"])
        .Width(60);
        })
        .Sortable()
        .Pageable()
    //.Scrollable()
        .ClientDetailTemplateId("template")
        .Scrollable(a => a.Height("auto"))
        .Filterable()
        .DataSource(dataSource => dataSource
                        .Ajax().Read(read => read.Action("claimCompanyUserList", "ExpenseGroup1")).PageSize(10)
        )
        .Events(events => events.DataBound("dataBound"))

這是子網格作為聚合網格-

<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<ClaimListbyCompanyUserId1_Result>()
            .Name("grid_#=ClaimId#")
            .Pageable(p => p.Enabled(false))
          .Sortable(s => s.Enabled(false))
          .Groupable(g => g.Enabled(true))
          .Scrollable(s => s.Enabled(false))
        //.Groupable(groupable => groupable.Enabled(true))
            .Columns(columns =>
            {
                columns.Bound(o => o.ItemDescription)
                    .Width(110)
                    .Title(@objFieldNameList["Description"]);

                columns.Bound(e => e.ItemAmount)
                .Title(@objFieldNameList["Amount"])
                .ClientGroupFooterTemplate("Total Amount: #=sum#")
                .Width(100);

                columns.Bound(e => e.CountryName)
                .Title(@objFieldNameList["Country"])
                .ClientGroupFooterTemplate("Count: #=count#")
                .Width(80);

            }).Events(e => e.DataBound("ChildGridDatabound"))
        .DataSource(dataSource => dataSource.Ajax()
        .Aggregates(aggregates =>
    {
        aggregates.Add(p => p.CountryName).Count();
        aggregates.Add(p => p.ItemAmount).Sum();
    })
    .Group(groups => groups.Add(p => p.ClaimTypeId))
    .Read(read => read.Action("GetClaimInnerGridByClaimId", "ExpenseGroup1", new { ClaimId = "#=ClaimId#" }))).ToClientTemplate())

錯誤:JavaScript運行時錯誤,“ sum”未定義
嘗試了所有可能的解決方案,但給出了相同的錯誤
請幫助,如果有人有解決方案
提前致謝

您的HTML代碼:

columns.Bound(e => e.ItemAmount)
            .Title(@objFieldNameList["Amount"])
            .ClientGroupFooterTemplate("Total Amount: #=sum#")
            .Width(100);

將上述HTML代碼替換為:

 columns.Bound(e => e.ItemAmount)
            .Title(@objFieldNameList["Amount"])
            .ClientGroupFooterTemplate("Total Amount: #= kendo.toString(sum,'c')")
            .Width(100);

死靈書(:
您的密碼

...
.ClientGroupFooterTemplate("Total Amount: #=sum#")
.ClientGroupFooterTemplate("Count: #=count#")
...

您可以使用雙反斜杠轉義哈希字符。
將上述HTML代碼替換為:

...
.ClientGroupFooterTemplate("Total Amount: \\#=sum\\#")
.ClientGroupFooterTemplate("Count: \\#=count\\#")
...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM