Column Footer not updated

7 posts, 1 answers
  1. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 24 Aug 2010 Link to this post

    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

  2. Dave
    Dave avatar
    23 posts
    Member since:
    Feb 2010

    Posted 24 Aug 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 25 Aug 2010 Link to this post

    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
  5. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Aug 2010 Link to this post

    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
  6. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 30 Aug 2010 Link to this post

    Dear Maya

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

    Best regards

    Christian
  7. Rakhi
    Rakhi avatar
    10 posts
    Member since:
    Aug 2010

    Posted 30 Aug 2010 Link to this post

    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
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Sep 2010 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready