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

How do you change the text alignment of aggregate functions in the footer?

2 Answers 347 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Geoff Hardy
Top achievements
Rank 1
Geoff Hardy asked on 24 Jun 2010, 10:01 PM
In my RadGridView, I have a column with TextAlignment="Right". In the footer for this column I would like to use the SumFunction to show the total of the values in this column. I would like the total in the footer to be right-aligned, like the cells on each row are.

Is there an easy way to do this?

2 Answers, 1 is accepted

Sort by
0
Christophe
Top achievements
Rank 1
answered on 25 Jun 2010, 08:19 AM
I'm interesting too
0
Maya
Telerik team
answered on 25 Jun 2010, 10:26 AM
Hello Geoff Hardy,

You can use the Property of the grid FooterTextAlignment and set it to "Right". Thus the definition of your column could be:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" TextAlignment="Right" FooterTextAlignment="Right">                  
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="Players:" />
                    </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
 

All the best,
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
Rodney
Top achievements
Rank 1
commented on 21 Aug 2021, 01:41 AM

What if there are 2 rows in the aggregate? It looks like it right aligns the block, but left aligns the contents.
Dilyan Traykov
Telerik team
commented on 24 Aug 2021, 11:27 AM

In this case, you would need to override the ItemTemplate of the AggregateResultsList:

                <Style TargetType="telerik:AggregateResultsList">
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" Text="{Binding Caption}"/>
                                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" Text="{Binding FormattedValue}"/>
                                </StackPanel>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

You can also bind these properties to the FooterTextAlignment property of the column by creating an appropriate converter:

HorizontalAlignment="{Binding DataColumn.FooterTextAlignment, RelativeSource={RelativeSource AncestorType=telerik:GridViewFooterCell}, Converter={StaticResource AlignmentConverter}}"

For your convenience, I've gone ahead and prepared a small sample project which demonstrates how you can implement this.

Please have a look and let me know if it provides the desired result.
Tags
GridView
Asked by
Geoff Hardy
Top achievements
Rank 1
Answers by
Christophe
Top achievements
Rank 1
Maya
Telerik team
Share this question
or