Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Server aggregates wrong

$
0
0

Hi,

I'm having a problem with the aggregates on my server-bound grid. Here's my code:

@(Html.Kendo().Grid(Model[j].BusinessUnitTimesheets)
    .Name("BU_Time" + j)
        .DataSource(d => d
            .Server()
            .Aggregates(ag =>
            {
                ag.Add(a => a.Amount).Sum();
                ag.Add(a => a.Hours).Sum();
            })
        )
    .Columns(columns =>
    {
        columns.Bound(c => c.BusinessUnitId)
            .Hidden();
        columns.Bound(c => c.BusinessUnitCodeAndName)
            .Title("Business Unit")
            .ClientFooterTemplate("Total");
        columns.Bound(c => c.Hours)
            .Format("{0:N2}")
            .HtmlAttributes(new { style = "text-align:right;" })
            .ClientFooterTemplate("#=sum#")
            .FooterHtmlAttributes(new { style = "text-align:right;" });
        columns.Bound(c => c.Amount)
            .Width(100).Format("{0:N2}")
            .HtmlAttributes(new { style = "text-align:right;" })
            .ClientFooterTemplate("#=kendo.toString(sum,'N2')#")
            .FooterHtmlAttributes(new { style = "text-align:right;" });
    })
    .DetailTemplate(
        @<text>
        @(Html.Kendo().Grid(item.UserTime)
            .Name(string.Format("BU_U_Time{0}_{1}", j, item.BusinessUnitId))
            .DataSource(d => d
                .Server()
                .Aggregates(ag =>
                {
                    ag.Add(a => a.Hours).Sum();
                    ag.Add(a => a.Amount).Sum();
                })
            )
            .Events(e => e.DataBinding("splitBound"))
            .Columns(columns =>
            {
                columns.Bound(c => c.UserName)
                    .Title("User");
                columns.Bound(c => c.Hours)
                    .Format("{0:N2}")
                    .HtmlAttributes(new { style = "text-align:right;" })
                    .ClientFooterTemplate("#=sum#")
                    .FooterHtmlAttributes(new { style = "text-align:right;" });
                columns.Bound(c => c.Amount)
                    .Width(100)
                    .Format("{0:N2}")
                    .HtmlAttributes(new { style = "text-align:right;" })
                    .ClientFooterTemplate("#=kendo.toString(sum,'N2')#")
                    .FooterHtmlAttributes(new { style = "text-align:right;" });
            })
        )
        </text>
    )
)

 

I've attached a screenshot of the rendered grid. The totals are in the wrong columns for the parent grid, and both parent and child have sums that are zero.

 

Thanks


Viewing all articles
Browse latest Browse all 78072

Trending Articles