RadGridView - Grid with 2 or more Footers

1 Answer 15 Views
GridView
James
Top achievements
Rank 1
James asked on 23 May 2025, 12:24 PM
I currently have a function grid similar to:



<telerik:RadGridView Grid.Row="2" Grid.ColumnSpan="2" x:Name="MyGridView"
                     ItemsSource="{Binding MyItems}"
                     RowIndicatorVisibility="Collapsed"
                     ShowColumnFooters="True"
                     ShowGroupPanel="False"
                     IsReadOnly="True"
                     HorizontalContentAlignment="Stretch"
                     VerticalAlignment="Top">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding MonthDisplay}" Header="Month" Width="65">
            <telerik:GridViewDataColumn.Footer>
                <TextBlock Text="Totals:"/>
            </telerik:GridViewDataColumn.Footer>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column1Data}" Header="Column 1" Width="*" MinWidth="40" MaxWidth="95" DataFormatString="#,###0.##" TextAlignment="Right" FooterTextAlignment="Right">
            <telerik:GridViewDataColumn.AggregateFunctions>
                <telerik:SumFunction/>
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column2Data}" Header="Column 2" Width="*" MinWidth="40" MaxWidth="95" DataFormatString="#,###0.##" TextAlignment="Right" FooterTextAlignment="Right">
            <telerik:GridViewDataColumn.AggregateFunctions>
                <telerik:SumFunction/>
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column3Data}" Header="Column 3" Width="*" MinWidth="40" MaxWidth="95" DataFormatString="#,###0.##" TextAlignment="Right" FooterTextAlignment="Right">
            <telerik:GridViewDataColumn.AggregateFunctions>
                <telerik:SumFunction/>
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Column4Data}" Header="Column 4" Width="*" MinWidth="40" MaxWidth="95" DataFormatString="#,###0.##" TextAlignment="Right" FooterTextAlignment="Right">
            <telerik:GridViewDataColumn.AggregateFunctions>
                <telerik:SumFunction/>
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

So the grid would show results like:


Month	Column1	Column2	Column3	Column4
Jan	1	2	3	4
Feb	1	2	3	4
March	1	2	3	4
Totals:	3	6	9	12


What I now want to do is add another footer row so that the grid would look like:

Month	Column1	Column2	Column3	Column4
Jan	1	2	3	4
Feb	1	2	3	4
March	1	2	3	4
Totals:	3	6	9	12
Average:1	2	3	4
Is it possible to add a 2nd footer row and  if so how can I accomplish that?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 26 May 2025, 04:49 PM

Hello James,

You cannot add a second footer row, but you can extend the content in the one that is assigned through the Footer property of the column. For example:

<telerik:GridViewDataColumn.Footer>
	<StackPanel>
		<TextBlock Text="Totals:"/>
		<TextBlock Text="Average:"/>
	</StackPanel>
</telerik:GridViewDataColumn.Footer>

Additional to that, you can check if the Caption property of the functions would work for you. It will allows you to display text next to the function's aggregate result.

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

James
Top achievements
Rank 1
commented on 04 Jun 2025, 06:50 PM

I am noticing some strange behavior.

I have a column

<telerik:GridViewDataColumn DataMemberBinding="{Binding Column4Data}" Header="Column 4" Width="*" MinWidth="40" MaxWidth="95" DataFormatString="#,###0.##" TextAlignment="Right" FooterTextAlignment="Right">
            <telerik:GridViewDataColumn.AggregateFunctions>
                <telerik:SumFunction/>
                <telerik:AverageFunction ResultFormatString="{}{0:0}" />
            </telerik:GridViewDataColumn.AggregateFunctions>
        </telerik:GridViewDataColumn>

However the data looks like this:

Column4

           4

           2

           6                      - The SumFunction

          3                       - The Average Function (it does not fully right align like the SumFunction

Martin Ivanov
Telerik team
commented on 05 Jun 2025, 12:01 PM

You can try to add the following style:

 <telerik:RadGridView.Resources>
     <Style TargetType="telerik:AggregateResultsList">
         <Style.Resources>
             <Style TargetType="ContentPresenter">
                 <Setter Property="HorizontalAlignment" Value="Right" />
             </Style>
         </Style.Resources>                    
     </Style>
 </telerik:RadGridView.Resources>

I also attached a sample project. I hope it helps.

 

James
Top achievements
Rank 1
commented on 05 Jun 2025, 05:43 PM

It did not work in my case.  When it was added the totals dont display.
Martin Ivanov
Telerik team
commented on 06 Jun 2025, 07:09 AM

This may happen if you use the Telerik's NoXaml dlls. In this case you should set the BasedOn property of the Style.

 <Style TargetType="telerik:AggregateResultsList" BasedOn="{StaticResource AggregateResultsListStyle}">

If this doesn't help feel free to send a project showing the problem or modify mine.

James
Top achievements
Rank 1
commented on 06 Jun 2025, 05:36 PM

That worked thanks!
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or