AggregateFunctions() & CalculateAggregates not wokring on dynamic columns

2 posts, 0 answers
  1. chillfire
    chillfire avatar
    9 posts
    Member since:
    Apr 2008

    Posted 10 Jun 2014 Link to this post


    I am having a problem getting the column totals updating after a cell has been edited in a RadGridView.
    The columns are all (bar one) generated at runtime in the code behind (not MVVM).

    My XAML;

    <telerik:RadGridView   Margin="6" 
       ItemsSource="{Binding PromotionVolumes}" 
       IsReadOnly="{Binding CurrentPromotion.IsReadOnly}" 
                                        <telerik:GridViewDataColumn Header="Product Name"
                                            DataMemberBinding="{Binding Path=Product.DisplayName}"
                                           Width="170" IsReadOnly="True">
                                                <telerik:CountFunction Caption="Count: " />

    I generate the columns, one for each item in an array of data;

              var b = new Binding(string.Format("Measures[{0}].RawValue", i));
                       var column = new GridViewDataColumn
                               DisplayIndex = i + existingColumnCount,
                               UniqueName = (i + existingColumnCount).ToString(),
                               Header = measures[i].Name,
                               DataMemberBinding = new Binding(string.Format("Item[{0}].Value", i)),
                               MinWidth = 90,
                               IsReadOnlyBinding = new Binding(string.Format("Item[{0}].IsReadOnly", i)),
                               Tag = new Binding(string.Format("Item[{0}].RawValue", i))

                       if (measures[i].IsCalculate)
                           column.DataMemberBinding.Mode = BindingMode.TwoWay;
                           column.DataMemberBinding.UpdateSourceTrigger = UpdateSourceTrigger.Default;

                           var sf = new SumFunction() { Caption = "", SourceField = b.Path.Path, SourceFieldType = typeof(decimal), ResultFormatString = "{0:N0}" };


    When cell editing happens I call;

          private void dgProducts_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)

    Ordering the grid has no effect on the footer totals either.

    I have seen other posts on the forums going back to 2009 and apparently this has been fixed?
    What am I missing?


  2. Nick
    Nick avatar
    593 posts

    Posted 11 Jun 2014 Link to this post

    Hello Craig,

    I suspect the problem is that the Aggregate functions cannot access the indexed property which you are bound to. You can check the Output window for BindingExpression errors which will indicate that indeed this is the problem. Furthermore, I cannot say anything with certainty without having the whole picture. Can you share the collection you are using with the indexer? 

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