This is a migrated thread and some comments may be shown as answers.

Aggregates when using BindTo

1 Answer 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel Knoll
Top achievements
Rank 1
Daniel Knoll asked on 06 Feb 2013, 10:42 AM
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)
)

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 08 Feb 2013, 08:50 AM
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!
Daniel Knoll
Top achievements
Rank 1
commented on 08 Feb 2013, 01:27 PM

That's working. Thank you very much.
Surya
Top achievements
Rank 1
commented on 28 Dec 2022, 06:13 PM

Hello, running into the same issue but in .NET Core .. Server is not valid. Could you please let me know what'd work
Mihaela
Telerik team
commented on 30 Dec 2022, 08:25 AM

Hi Surya, 

Generally, the Telerik UI for ASP.NET Core Grid does not support server binding as available in Telerik UI for ASP.NET MVC. You can find the available types of data binding in the following section of the Grid documentation:

https://docs.telerik.com/aspnet-core/html-helpers/data-management/grid/binding/overview

Tags
Grid
Asked by
Daniel Knoll
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or