Aggregates when using BindTo

3 posts, 0 answers
  1. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 06 Feb 2013 Link to this post

    Hi,

    I know how to specify aggregates when using a DataSource to populate the grid.

    But how do I define aggregates when I'm populating the Grid using BindTo?

    I want a Sum row at the bottom of this Grid:
    @(Html.Kendo().Grid<Models.AgentLeaderData>()
            .Name("AgentLeaderData")
            .Columns(col =>
            {
                col.Bound(p => p.AgentName);
                col.Bound(p => p.Revenue).HtmlAttributes(new { style = "text-align:right" });
            })
             
            .BindTo(Model.AgentLeaderData)
    )
  2. Daniel
    Admin
    Daniel avatar
    2230 posts

    Posted 08 Feb 2013 Link to this post

    Hello,

    In server binding mode the aggregates should specified the same way - through the DataSource Aggregates method. To show the sum in the footer you should use a FooterTemplate e.g.
    .Columns(col =>
    {
        col.Bound(p => p.AgentName);
        col.Bound(p => p.Revenue).FooterTemplate(@<text>Sum: @item.Sum</text>).HtmlAttributes(new { style = "text-align:right" });
    })
    .DataSource(dataSource => dataSource
        .Server()
        .Aggregates(aggregates =>
        {
            aggregates.Add(p => p.Revenue).Sum();
        })
    We have a server aggregates demo available in the examples project included with the installation.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 08 Feb 2013 Link to this post

    That's working. Thank you very much.
Back to Top