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

Aggreates in grid footer need updating as user enters data

3 Answers 233 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 22 Nov 2013, 04:52 PM
I have a timesheet grid that is setup for batch editing. There are row totals and column totals and a bunch of decimal data in each cell. Each row has data for Monday through Friday for the first week and Mo-Fri for the second week.  Totals are updated for Week 1 and Week2 as well as the 2 week total. Individual lines in the grid represent projects that are being billed against.

I have the grid set up to calculate the row totals as the user enters information in each cell and tabs to the next by hooking into the gridSave event and running javascript to do a running total and updating the row total field. Here's an example.

//Calculate week sums and total sums
   function gridSave(e) {
 
       
           var Mo1_time = e.values.Mo1_time,
                Tu1_time = e.model.Tu1_time,
                We1_time = e.model.We1_time,
                Th1_time = e.model.Th1_time,
                Fr1_time = e.model.Fr1_time,
                Sa1_time = e.model.Sa1_time,
                Su1_time = e.model.Su1_time,
                Mo2_time = e.model.Mo2_time,
                Tu2_time = e.model.Tu2_time,
                We2_time = e.model.We2_time,
                Th2_time = e.model.Th2_time,
                Fr2_time = e.model.Fr2_time,
                Sa2_time = e.model.Sa2_time,
                Su2_time = e.model.Su2_time,
                Wk1_time = 0,
                Wk2_time = 0
 
           Wk1_time = Mo1_time + Tu1_time + We1_time + Th1_time + Fr1_time + Sa1_time + Su1_time;
           Wk2_time = Mo2_time + Tu2_time + We2_time + Th2_time + Fr2_time + Sa2_time + Su2_time;
 
           e.model.set("Wk1_time", Wk1_time);
           e.model.set("Wk2_time", Wk2_time);
 
           e.model.set("Sum_time", Wk1_time + Wk2_time);
       }

What I'd like to do is expand this to also do a column total and update the aggregate in the footer, but I'm not sure how to do this. (Need to have a total for each day of the week). Right now I have it set so that the aggregates properly calculate column totals and display when the grid data is first loaded from the controller, but then they are static until all data is saved and the grid is re-populated. I need real-time updates.

Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 26 Nov 2013, 03:15 PM
Hello Randy,

If you are using server aggregates then refer to a similar question here:

http://www.kendoui.com/forums/kendo-ui-framework/data-source/aggregates-is-not-recalculated-on-update-destroy.aspx

In case you use clientAggregates then you will need to redraw the Grid with its refresh method when the save event is triggered.

Here is an example:

http://jsbin.com/aPaNIpOS/2/edit

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Francis
Top achievements
Rank 1
answered on 14 May 2014, 01:35 PM
Petur,
I am trying a similar screen and need client side aggregate operation.  I cannot change the value in your client side example.  The grid save event is fired when you click on a cell, and when you change the content, doing a refresh on the grid redraws it and the edit mode is lost.  So that is not a solution.  Probably need to have a re-compute aggregates either on the datasource or on the grid.
0
Petur Subev
Telerik team
answered on 15 May 2014, 08:23 AM
Hello Randy,

I am afraid there is no other work-around that I can suggest at this point.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Randy
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Francis
Top achievements
Rank 1
Share this question
or