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

Column footer problem

1 Answer 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adrian Guillen
Top achievements
Rank 1
Adrian Guillen asked on 09 Dec 2009, 10:25 PM
I have in my .xaml the following code:

<telerik:RadGridView x:Name="radGridView1" IsReadOnly="True" Grid.Column="1" Grid.Row="1" Margin="0,0,0,5" Grid.RowSpan="3"
    <telerik:RadGridView.Columns> 
                
    <telerik:GridViewDataColumn Header="Mesa" DataMemberBinding="{Binding mesa}"
        <telerik:GridViewColumn.AggregateFunctions> 
            <telerik:CountFunction Caption="# Registros encontrados: " /> 
        </telerik:GridViewColumn.AggregateFunctions>      
    </telerik:GridViewDataColumn> 
    <telerik:GridViewDataColumn x:Name="efectivo" Header="efectivo" DataMemberBinding="{Binding efectivo}"
        <telerik:GridViewColumn.AggregateFunctions> 
            <telerik:SumFunction Caption="Total: " /> 
        </telerik:GridViewColumn.AggregateFunctions> 
    </telerik:GridViewDataColumn> 

    .
    .
    .
    .

the count function works but the sum function doesn't, it says in spanish something like "There isn't a 'Sum' method in the 'System.Linq.Enumerable' type, compatible with the specified arguments."
The ItemSource that i'm binding is an Arraylist that contains objects of an object type that i created.


ArrayList listaMesas = Oper_SoftCount.consultarFecha(dt); 
this.radGridView1.ItemsSource = listaMesas


and the other problem is that the columns that have the aggregate functions, duplicate.

<telerik:GridViewDataColumn Header="Mesa" DataMemberBinding="{Binding mesa}">
                    <telerik:GridViewColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="# Registros encontrados: " />
                    </telerik:GridViewColumn.AggregateFunctions>     
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn x:Name="efectivo" Header="efectivo" DataMemberBinding="{Binding efectivo}">
                    <telerik:GridViewColumn.AggregateFunctions>
                        <telerik:SumFunction Caption="Total: " />
                    </telerik:GridViewColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 10 Dec 2009, 03:55 PM
Hi Adrian Guillen,

1. Please use a generic List or IEnumerable instead of an ArrayList. This will save you a lot of trouble.

2. Please define the SourceField for the SumFunction.

3. Set AutoGenerateColumns to False.

I have prepared a sample project. Here are the key parts:

<Window x:Class="TicketID_265574_AggregateFunctions.Window1"
    xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data"
    Title="Window1" Height="700" Width="600">
    <Grid>
        <telerik:RadGridView Name="playersGrid"
                             AutoGenerateColumns="False"
                             ShowColumnFooters="True"
                             ColumnsWidthMode="Auto">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Name"
                                    DataMemberBinding="{Binding Name}">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Number"
                                    DataMemberBinding="{Binding Number}">
                    <telerik:GridViewColumn.AggregateFunctions>
                        <telerikData:SumFunction Caption="The sum is:"
                                                 SourceField="Number"/>
                    </telerik:GridViewColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Position"
                                    DataMemberBinding="{Binding Position}">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Country"
                                    DataMemberBinding="{Binding Country}">
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using System.Collections;
using System.Collections.Generic;
 
namespace TicketID_265574_AggregateFunctions
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
 
            IEnumerable<Player> players = Club.GetPlayers();
            this.playersGrid.ItemsSource = players;
        }
    }
}

Please, examine the sample project. I hope it helps.


Sincerely yours,
Ross
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
Adrian Guillen
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or