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

AggregateFunctions Footer not working

4 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 2
Chris asked on 19 Nov 2009, 12:47 AM
RadControls for WPF Q3 2009.

I have an ObservableCollection<T> with a class that implements INotifyPropertyChanged, bound to a RadGridView.

A column on the RadGridView implements a GridViewDataColumn for summing and displaying in a footer.

The Sum, shows up correctly upon running the application, however whenever a cell is edited, the sum does not update to reflect the new figure.
Am I supposed to invoke something to update the column sum?

Additionally, Columns are right aligned.  Upon entering a leaving the cell, the data is left aligned.  Is this a bug?

using System;  
using System.ComponentModel;  
 
public class Product : INotifyPropertyChanged  
{
    #region fields  
    private string _id;  
    private string _name;  
    private double _unitPrice;  
    private DateTime _date;
    #endregion  
 
    #region ctor  
    public Product()  
    {  
 
    }  
 
    public Product(string id, string name, double unitPrice, DateTime date)  
    {  
        _id = id;  
        _name = name;  
        _unitPrice = unitPrice;  
        _date = date;  
    }
    #endregion  
 
    #region properties  
    public string ID  
    {  
        get { return _id; }  
        set 
        {  
            _id = value;  
            NotifyPropertyChanged("ID");  
        }  
    }  
 
    public string Name  
    {  
        get { return _name; }  
        set 
        {  
            _name = value;  
            NotifyPropertyChanged("Name");  
        }  
    }  
 
    public double UnitPrice  
    {  
        get { return _unitPrice; }  
        set 
        {  
            _unitPrice = value;  
            NotifyPropertyChanged("UnitPrice");  
        }  
    }  
 
    public DateTime Date  
    {  
        get { return _date; }  
        set 
        {  
            _date = value;  
            NotifyPropertyChanged("Date");  
        }  
    }
    #endregion  
 
    #region Interface INotifyPropertyChanged  
    public event PropertyChangedEventHandler PropertyChanged;  
 
    private void NotifyPropertyChanged(string propertyName)  
    {  
        if (PropertyChanged != null)  
            PropertyChanged(thisnew PropertyChangedEventArgs(propertyName));  
    }
    #endregion  
}  
 

public Window6()  
{  
    InitializeComponent();  
 
 
    ObservableCollection<Product> list2 = new ObservableCollection<Product>();  
    list2.Add(new Product("A""Apple", 11.23, DateTime.Now));  
    list2.Add(new Product("B""Banana", 1.123, DateTime.Now));  
    list2.Add(new Product("C""Cherry", 112.3, DateTime.Now));  
    list2.Add(new Product("D""Durian", 12.3, DateTime.Now));  
    list2.Add(new Product("E""Eggplant", 1.23, DateTime.Now));  
    list2.Add(new Product("F""Fireberry", .123, DateTime.Now));  
    list2.Add(new Product("G""Golfball", 1.12, DateTime.Now));  
    list2.Add(new Product("H""Help", 1.13, DateTime.Now));  
 
    Binding binding = new Binding();  
    binding.Source = list2;  
    RadGridView1.SetBinding(RadGridView.ItemsSourceProperty, binding);  

<grid:RadGridView Grid.Row="1" Margin="0,0,0,1" x:Name="RadGridView1" ItemsSource="{Binding RandomProducts}" ShowColumnFooters="True" ShowGroupFooters="True" Width="900" 
             AutoGenerateColumns="False" IsReadOnly="False" CanUserFreezeColumns="False">  
    <grid:RadGridView.Columns> 
        <grid:GridViewDataColumn Header="ID" DataMemberBinding="{Binding ID}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:CountFunction Caption="Count: " /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:MinFunction FunctionName="MinUnitPrice" ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
            <grid:GridViewDataColumn.Footer> 
                <Button Content="Show smallest UnitPrice" Click="Button_Click" Margin="5,0" /> 
            </grid:GridViewDataColumn.Footer> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Width="200" Header="Unit Price" TextAlignment="Right" DataMemberBinding="{Binding UnitPrice}" DataFormatString="{}{0:c}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:SumFunction Caption="Sum: " ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
                <data:AverageFunction Caption="Average: " ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
            <grid:GridViewDataColumn.Footer> 
                <StackPanel Orientation="Vertical" Margin="5,0">  
                    <TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" /> 
                    <gridView:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">  
                        <ItemsControl.ItemTemplate> 
                            <DataTemplate> 
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">  
                                    <TextBlock VerticalAlignment="Center" Text="{Binding Caption}" /> 
                                    <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" /> 
                                </StackPanel> 
                            </DataTemplate> 
                        </ItemsControl.ItemTemplate> 
                        <ItemsControl.ItemsPanel> 
                            <ItemsPanelTemplate> 
                                <StackPanel Orientation="Vertical" /> 
                            </ItemsPanelTemplate> 
                        </ItemsControl.ItemsPanel> 
                    </gridView:AggregateResultsList> 
                </StackPanel> 
            </grid:GridViewDataColumn.Footer> 
            <grid:GridViewDataColumn.GroupFooterTemplate> 
                <DataTemplate> 
 
                    <StackPanel Orientation="Vertical" Margin="5,0">  
                        <TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" /> 
                        <gridView:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">  
                            <ItemsControl.ItemTemplate> 
                                <DataTemplate> 
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">  
                                        <TextBlock VerticalAlignment="Center" Text="{Binding Caption}" /> 
                                        <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" /> 
                                    </StackPanel> 
                                </DataTemplate> 
                            </ItemsControl.ItemTemplate> 
                            <ItemsControl.ItemsPanel> 
                                <ItemsPanelTemplate> 
                                    <StackPanel Orientation="Vertical" /> 
                                </ItemsPanelTemplate> 
                            </ItemsControl.ItemsPanel> 
                        </gridView:AggregateResultsList> 
                    </StackPanel> 
                </DataTemplate> 
 
            </grid:GridViewDataColumn.GroupFooterTemplate> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Width="200" Header="Date" DataMemberBinding="{Binding Date}" DataFormatString="{}{0:d}" TextAlignment="Right">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:MinFunction Caption="Min: " ResultFormatString="{}{0:d}" SourceField="Date" /> 
                <data:MaxFunction Caption="Max: " ResultFormatString="{}{0:d}" SourceField="Date" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
        </grid:GridViewDataColumn> 
    </grid:RadGridView.Columns> 
</grid:RadGridView> 
 

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 19 Nov 2009, 03:03 PM
Hi Chris,

Thank you for your feedback ! . I have updated your Telerik points. Meanwhile we have identified and fixed the bug. It will be available for download in our very next internal build .

Please excuse us for the inconvenience caused .

Kind regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chris
Top achievements
Rank 2
answered on 22 Nov 2009, 10:04 PM
Thankyou.  Having working sums is very important. :)
0
Sean O'Dea
Top achievements
Rank 1
answered on 24 Nov 2009, 02:01 AM
This problem still exists in version 2009.3.1120.35.
0
Vlad
Telerik team
answered on 27 Nov 2009, 07:12 AM
Hi,

I've just tried this however everything worked fine - you can check the attached project for reference.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Chris
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Chris
Top achievements
Rank 2
Sean O'Dea
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or