"Uncaught ReferenceError: sum is not defined" when grouping grid

4 posts, 0 answers
  1. Uwe
    Uwe avatar
    10 posts
    Member since:
    Mar 2008

    Posted 13 Nov 2012 Link to this post

    Dear support

    Currently working on a MVC 4 project, I get an error when using a group footer template for a field in a grid:
    groupFooterTemplate: "#= sum #"
    The above line results in an error

    "Uncaught ReferenceError: sum is not defined"

    when grouping the grid.

    I've included a stand-alone proof-of-concept project. The file "Index.cshtml" contains some comments in line 91 and 99 to highlight the row that procudes the error.

    My question is:

    Could you please kindly take a look at my attached project and tell me how I should change the code so that the sum is correctly printed in the footer of a cell?

    Thanks
    Uwe
  2. Uwe
    Uwe avatar
    10 posts
    Member since:
    Mar 2008

    Posted 13 Nov 2012 Link to this post

    Finally, I solved it.

    What I did was to forget to dynamically set the aggregates for the group.

    Old code:
    ds.group({ field: column });
    New code:
    ds.group({ field: column,
        aggregates:[
            { field: "Three", aggregate: "sum" },
            { field: "Four", aggregate: "sum" }] });
    So I'm just happy now :-)
  3. Kendo UI is VS 2017 Ready
  4. Matt
    Matt avatar
    5 posts
    Member since:
    Jun 2014

    Posted 07 Aug 2014 in reply to Uwe Link to this post

    I had a similar problem but it was because I put the aggregate code into the grid instead of into the datasource.

    // following is part of the datasource
    aggregate:[
            { field: "Three", aggregate: "sum" },
            { field: "Four", aggregate: "sum" }] });


  5. RUBEN
    RUBEN avatar
    8 posts
    Member since:
    Dec 2013

    Posted 12 Jun 2015 Link to this post

    In my case does not coincide with the model aggregate field.
    I had this

    columns.Bound(model => model.Monto1).Filterable(false).Format("{0:n0}").HtmlAttributes(new { align = "right" }).ClientFooterTemplate("<div style='float: right'>#= kendo.toString(sum, 'n0') #</div>").Title("mes1");

    ...
      .DataSource(dataSource => dataSource
        .Aggregates(aggregates =>
        {
            aggregates.Add(model => model.Monto2).Sum();
        })

     

    and the correct is:

    aggregates.Add(model => model.Monto1).Sum();

Back to Top
Kendo UI is VS 2017 Ready