Recalculate aggregates on demand

2 posts, 1 answers
  1. Mircea
    Mircea avatar
    2 posts
    Member since:
    Jun 2015

    Posted 15 Jun 2015 Link to this post

    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.

  2. Answer
    Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 17 Jun 2015 Link to this post

    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
Back to Top