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

Column Footer not updated

6 Answers 251 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 24 Aug 2010, 06:36 PM
Hi

My RadGridView is bound to some items that implement INotifyPropertyChanged. The grid's ShowColumnFooters property is True and there is a SumFunction in one of the columns. When the grid is initially loaded, the data is displayed fine and the total is correct.
However there is some feature that enables the user to update the values that are displayed in the column that has the total in the footer. This feature updates only one item's value at a time but it's not using editing within the grid but some other editing. When the value is updated, the detail row is changed accordingly but the total in the footer is not.

I have found out that when editing the value directly in the grid it's working as well as when adding or removing rows (i.e. total in the footer is updated).

So how can I programmatically instruct the grid to update its totals/footers if this is not done automatically?

Thanks and regards,

Christian

6 Answers, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 24 Aug 2010, 10:12 PM
Christian,

For what it's worth I would recommend that you calculate the total in the underlying object to which you have bound items. Calculate the total there and raise OnPropertyChanged for the total. Then just bind a TextBlock to this "Total" property. That way the logic to do the calculations is NOT in your UI layer.

I do something similar to this in an application I'm working on that has an order entry form. The line items view is bound to an object that exposes a list of line item objects as well as a subtotal, total and total tax columns. As the line items are edited, the total updates automatically.

Hope this helps.
Dave
0
Christian
Top achievements
Rank 1
answered on 25 Aug 2010, 10:15 AM
Hi Dave

Thank you very much for your input. I've used it to create a similar solution that works. For more advanced scenarios it's of course better not to have the summing in the UI. However for straight forward and basic cases it would be nice to have a way to use the builtin aggregation functions and have them updated when needed.

Thanks again and regards

Christian
0
Accepted
Maya
Telerik team
answered on 27 Aug 2010, 12:56 PM
Hi Christian Baer,

The recommended way for updating the aggregate result is to call the method of RadGridView CalculateAggregates() immediately after a change has been made.


Best wishes,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Christian
Top achievements
Rank 1
answered on 30 Aug 2010, 10:33 AM
Dear Maya

Thank you, that was exactly what I was looking for.

Best regards

Christian
0
Rakhi
Top achievements
Rank 1
answered on 30 Aug 2010, 10:58 AM
Hi
<telerikData:GridViewDataColumn Header="Net Amount" DataMemberBinding="{Binding NET_AMT}">
        <telerikData:GridViewDataColumn.AggregateFunctions>
<telerikagg:SumFunction Caption="Sum: " ResultFormatString="{}{0:c}" SourceField="NET_AMT" />
<telerikagg:AverageFunction Caption="Average: " ResultFormatString="{}{0:c}" SourceField="NET_AMT" />
     </telerikData:GridViewDataColumn.AggregateFunctions>
<telerikData:GridViewDataColumn.Footer>
         <telerikList:AggregateResultsList ItemsSource="{Binding}" ItemTemplate="{StaticResource colAggregation}" />
   </telerikData:GridViewDataColumn.Footer>
</telerikData:GridViewDataColumn>

i added 'colAggregation' as data templtae in window.resources
 <Window.Resources>
        <DataTemplate x:Key="colAggregation">
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="{Binding Path=Caption}"/>
                <TextBlock VerticalAlignment="Center" Text="{Binding Path=FormattedValue}"/>
            </StackPanel>
        </DataTemplate>
</Window.Resources>

Please tell me how can i do this at run time i.e. create columns with footer for aggregate functions.
Please reply soon.
Thanks
0
Maya
Telerik team
answered on 02 Sep 2010, 01:20 PM
Hi Rakhi,

You may take a look at this forum thread as a reference.
 

Sincerely yours,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Christian
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Christian
Top achievements
Rank 1
Maya
Telerik team
Rakhi
Top achievements
Rank 1
Share this question
or