Aggregates 0 when initially bound to model using ajax binding

2 posts, 0 answers
  1. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 28 Mar 2013 Link to this post

    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:

               .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;" });
               .Sortable(s => s.AllowUnsort(false))
               .DataSource(ds => ds
                   .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.
  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 29 Mar 2013 Link to this post

    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!
Back to Top