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

Aggregates 0 when initially bound to model using ajax binding

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 28 Mar 2013, 06:31 AM
Hi,
I don't know if I'm doing something wrong but I have a page with a grid that is populated with IQueryable<Grant> data initially using BindTo and are ajax bound with aggregates.  When the page loads, the aggregate total (sum) shows 0.  As soon as I sort or page the aggregates are populated so I'm not sure what's going on. 

My grid is as follows:

@(Html.Kendo().Grid<Grant>()
           .Name("gd-gt")
           .BindTo(Model.Grants)
           .Columns(c =>
           {
               c.Bound(g => g.GrantDate).Width(90).Format("{0:MM/dd/yyyy}").HtmlAttributes(new { style = "text-align:center;" });
               c.Bound(g => g.ResultText).Title("Special Result").Sortable(false);
               c.Bound(g => g.Amount).Format("{0:C2}").Width(80).HtmlAttributes(new { style = "text-align:right;" })
                           .ClientFooterTemplate("#=kendo.toString(sum, 'C2')#").FooterHtmlAttributes(new { style = "text-align:right;" });
           })
           .Pageable()
           .Sortable(s => s.AllowUnsort(false))
           .DataSource(ds => ds
               .Ajax()
               .ServerOperation(true)
               .PageSize(5)
               .Aggregates(aggregates =>
               {
                   aggregates.Add(g => g.Amount).Sum();
               })
 
               .Model(model =>
               {
                   model.Id(m => m.GrantId);
               })
               .Read(read => read.Action("LoadGrants", "Home", new { caseId = caseId }))
               .Sort(s => { s.Add(g => g.GrantDate).Descending(); })
               ))
         )
Any suggestions?

Thank you.
David A.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 29 Mar 2013, 02:13 PM
Hello David,

Basically ServerOperation(true) means that the data will be processed on the server side and it will only be displayed when it is sent to the client. 
So you need to consider to:
  • Remove the collection passed directly to the BindTo method
  • Set ServerOperation to false

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
David A.
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or