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

[Solved] How to recalculate custom aggregates

3 Answers 239 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Thomas
Top achievements
Rank 1
Thomas asked on 18 Jul 2011, 09:37 PM
Please Help,

I have created several custom aggregates which calculation depends of other piece of the data, i.e. agg1 depends on agg2 and agg3.
When I am changing data for a column1 it calculates properly but column2 and column3 aggregates are not refresh.
 I've tried to do a rebind on the grid which   does not work either.

Also, I've tried CalculateAggregates which does not work as well.
    ...
           <telerik:GridViewDataColumn Header="Sep"
                                            IsFilterable="False"
                                            DataMemberBinding="{Binding P11, Mode=TwoWay}"
                                            DataFormatString="{}{0:C0}"
                                            GroupFooterTemplate="{StaticResource footerTemplate}">
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:SumFunction SourceField="P11"
                                             ResultFormatString="{}{0:C0}" />
                        <Controls:GrossProfitP11 FunctionName="GPP11"
                                                ResultFormatString="{}{0:C0}"
                                                Caption="GP:" />
 
                        <Controls:GrossMarginP11 FunctionName="GMP11"
                                                ResultFormatString="{}{0:P2}"
                                                Caption="GM:" />
                        <Controls:OperationIncomeP11 FunctionName="OIP11"
                                                    ResultFormatString="{}{0:C0}"
                                                    Caption="OI:" />
                        <Controls:NetIncomeP11 FunctionName="NIP11"
                                              ResultFormatString="{}{0:P2}"
                                              Caption="NI:" />
 
                    </telerik:GridViewDataColumn.AggregateFunctions>
 
 
 
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Oct"
                                            IsFilterable="False"
                                            DataMemberBinding="{Binding P12, Mode=TwoWay}"
                                            DataFormatString="{}{0:C0}"
                                            GroupFooterTemplate="{StaticResource footerTemplate}">
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:SumFunction SourceField="P12"
                                             ResultFormatString="{}{0:C0}" />
                        <Controls:GrossProfitP12 FunctionName="GPP12"
                                                ResultFormatString="{}{0:C0}"
                                                Caption="GP:" />
 
                        <Controls:GrossMarginP12 FunctionName="GMP12"
                                                ResultFormatString="{}{0:P2}"
                                                Caption="GM:" />
                        <Controls:OperationIncomeP12 FunctionName="OIP12"
                                                    ResultFormatString="{}{0:C0}"
                                                    Caption="OI:" />
                        <Controls:NetIncomeP12 FunctionName="NIP12"
                                              ResultFormatString="{}{0:P2}"
                                              Caption="NI:" />
 
                    </telerik:GridViewDataColumn.AggregateFunctions>
 
 
 
                </telerik:GridViewDataColumn>
 
                <telerik:GridViewExpressionColumn Header="%"
                                                  UniqueName="CalcPercent"
                                                  DataFormatString="{}{0:P2}"
                                                  />
 
                <telerik:GridViewDataColumn Header="Active"
                                            DataMemberBinding="{Binding IsActive}"
                                            IsReadOnly="True" />
            </telerik:RadGridView.Columns>
            <telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor Member="GroupNameSorted"
                                         SortDirection="Ascending">
 
                </telerik:GroupDescriptor>
 
...

So, if any of my fields P1 .... P12 changes I need to force recalculation on all fields P1..P12
Also, I tried to raise property changed event for dependent properties

 

          partial void OnP1Changed()
        {
            this.RaisePropertyChanged("CalculatedTotal");
              this.RaisePropertyChanged("P2");
            this.RaisePropertyChanged("P3");
            this.RaisePropertyChanged("P4");
.......
      }








Can you sugest better solution?

BTW, Using MVVM pattern


3 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 19 Jul 2011, 03:54 PM
Additional Info;

Calculation are working at least I am hitting a break point.
The data is getting updated only for a group which is currently edited.
Value will get updated when comit edit is call (Edit/Comit) on the other groups.
0
Thomas
Top achievements
Rank 1
answered on 20 Jul 2011, 02:03 PM
I am still having this issue and it is kind of show stoper for me.
Can you guys help?
0
Maya
Telerik team
answered on 20 Jul 2011, 02:35 PM
Hi Thomas,

Generally, the aggregates should be updated by changing a corresponding value for a particular row. You may test it on our demos both for aggregates and custom aggregates. How are your aggregates implemented ? May you try to use a generic AggregateExpression instead ? May you try to handle the CellEditEnded event and update manually the aggregates ? 
 

Regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Thomas
Top achievements
Rank 1
Maya
Telerik team
Share this question
or