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

Recalculate aggregates on demand

1 Answer 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mircea
Top achievements
Rank 2
Mircea asked on 15 Jun 2015, 10:04 AM

Hi guys,

I have a grid with amounts for each month of the year which has totals for rows and columns. I use aggregates for column totals and a javascript function for the Totals column and the grand total.

This works nicely when a user edits a row. When he comes out of edit mode the totals are recalculated properly.

Now comes the problem. We have a change values functionality which allows the user to setup a pattern for changing values, eg: decrease by 10 percent where amount > X. I cannot use .set(value) for setting the amount since the grid sometimes has 7 pages and calling that for many cells has a huge performance impact.

So how can I have all aggregates recalculated at the end of my function execution?

I'll mention that changes are batched and saved only when user presses the Save button.

Thank you,

Mircea D.

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 17 Jun 2015, 08:58 AM
Hi,

If you are using client-side operations then the aggregates will be recalculated on change so you could either trigger the change event of an item or the dataSource data in order to update the aggregates:
var data = dataSource.data();
for (var i = 0; i < data.length; i++) {
    data[i].Foo = NewValue;
}
data.trigger("change");


Regards,
Daniel
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mircea
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or