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

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

3 Answers 1912 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Uwe
Top achievements
Rank 1
Uwe asked on 13 Nov 2012, 08:41 AM
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

3 Answers, 1 is accepted

Sort by
0
Uwe
Top achievements
Rank 1
answered on 13 Nov 2012, 12:24 PM
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 :-)
0
Matt
Top achievements
Rank 1
Veteran
answered on 07 Aug 2014, 08:11 AM
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" }] });


0
TISAL
Top achievements
Rank 1
answered on 12 Jun 2015, 05:11 PM

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();

Tags
Grid
Asked by
Uwe
Top achievements
Rank 1
Answers by
Uwe
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Veteran
TISAL
Top achievements
Rank 1
Share this question
or