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

[Solved] jquery error when using sum column with no rows

2 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
tim
Top achievements
Rank 1
tim asked on 14 Jun 2011, 05:33 PM
I Have a telerik grid that works fine , and sums up columns which are in a detailview - child grid
So when you click the expand column to see the child grid everything works fine apart from when there are no elements in
the child grid , so in this case we have a section as the top grid and questions below in the detail , expanding a section 
which has no questions receive the following jquery 1-5-1.min error


 Microsoft JScript runtime error: 'Sum' is undefined

This is the columns markup for the grid in question 
      .Columns(columns =>
                                                    {
                                                        columns.Bound(d => d.Ordinal);
                                                        columns.Bound(d => d.Name);
                                                        columns.Bound(d => d.Required);
                                                        columns.Bound(d => d.MarksAvailable)
                                                       .Aggregate(aggreages => aggreages.Sum()) // <-- Sum aggregate
                                                       .ClientFooterTemplate("Total Marks Available :<#= Sum #>");


any ideas how we can trap this if there are no errors ? or a fix ? 
Thanks
;

2 Answers, 1 is accepted

Sort by
0
Accepted
Pak
Top achievements
Rank 1
answered on 15 Jun 2011, 12:03 PM
Hi there

You will need to do this:

.ClientFooterTemplate("Total : <#= typeof Sum != 'undefined' ? Sum : 0 #>")


Cheers
0
tim
Top achievements
Rank 1
answered on 15 Jun 2011, 01:32 PM
thanks a lot
Tags
Grid
Asked by
tim
Top achievements
Rank 1
Answers by
Pak
Top achievements
Rank 1
tim
Top achievements
Rank 1
Share this question
or