Adding an AggregateFunction to a column at runtime does not show its result before resorting or grouping

3 posts, 1 answers
  1. Marcus
    Marcus avatar
    43 posts
    Member since:
    Aug 2012

    Posted 18 Jul 2014 Link to this post

    Hi support,

    I am adding a AggregateFunction to a gridcolumn with the following code:

    bool showFooter = false;
    foreach (var col in radGridView.Columns)
    {
        if (col.UniqueName == "dauer") // Column with double-values
        {
            col.AggregateFunctions.Add(new SumFunction() { ResultFormatString = strFormat, SourceField = col.UniqueName });
            showFooter = true;
        }
    }
    radGridView.ShowColumnFooters = showFooter;

    Adding a footer should only happens if my table has a column of data-type double named "dauer" otherwise columnfooters should not been shown. After doing this the footer has correctly been show but the first time the sum of the column is displayed when I sort a column of the grid via clicking on a column header.

    You can reproduce this behavior in your sample-program "persistence framework / gridview serialization" when you put these lines of code in function "OnLoad" of Example.xaml.cs after calling this.EnsureLoadState() (of course you have to add a new column "dauer" to your dataset)

    What do I have to do to show the results of the aggregate-function directly.

    Thanks in advance

    Marcus
  2. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 18 Jul 2014 Link to this post

    Hi Marcus,

    RadGridView will update the information on the aggregates added at runtime once a CollectionChanged notification is raised from the bound source collection.

    One way to do so is to apply any data operation - sorting, grouping or filtering. Another way would be to invoke RadGridView.CalculateAggregates() or RadGridView.Rebind() after you add the aggregate function.
    For example:
    ...
    radGridView.ShowColumnFooters = showFooter;
    radGridView.CalculateAggregates();

    How does this work for you?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. Marcus
    Marcus avatar
    43 posts
    Member since:
    Aug 2012

    Posted 18 Jul 2014 in reply to Dimitrina Link to this post

    Hi Didie,

    thanks, this works fine.

    Marcus
Back to Top