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

Trying to add total row to grid

2 Answers 753 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 08 Nov 2013, 08:15 PM
Hello,

I am trying to add a totals row to my grid, and I've boiled my problem down to a very simple jsfiddle:

http://jsfiddle.net/2efYE/20/

Note that there is an "Uncaught ReferenceError: sum is not defined" error.

If you replace "sum" in the footerTemplate with a static value (e.g. "100") then it works fine. I must be missing something very basic, but after spending a lot of time staring at the grid aggregates demo and experimenting, I still can't seem to figure it out. Maybe something unique to MVVM? Maybe you can't do aggregates without also grouping (although I tried it with groups, too)?

Thanks in advance for the help,
--Dan

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 11 Nov 2013, 08:23 AM
Hello Dan,

The footer template should be a bit more verbose in this scenario. Here is an example for this: http://jsbin.com/OwOPeQO/1/edit

The reason for this is because the grid is initialized by using MVVM. What happens is next:
 - kendo.bind is executed
  - it finds all DOM nodes with data-role attribute
  - initializes the widgets with that roles
   - grid is initialized and it attempts to bind, but its original/default DataSource doesn't have aggregates configured yet
  - on the above step completes kendo.bind sets widget options, i.e data source, columns etc.
  - then  the widget have proper DataSource configuration with aggregates

Hope this explains that happens behind the scene.

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dan
Top achievements
Rank 1
answered on 11 Nov 2013, 02:03 PM
Thanks for the help, Nikolay!
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Dan
Top achievements
Rank 1
Share this question
or