FooterTextAlignment with multiple AggregateFunctions

4 posts, 1 answers
  1. Robert
    Robert avatar
    23 posts
    Member since:
    Oct 2011

    Posted 21 Aug 2014 Link to this post

    I have a grid whose columns have multiple AggregateFunctions. The FooterTextAlignment for each column is set to Right, which results in the situation seen in the attached image. Seems like the footer cell itself is aligned to the right, but each line of text that corresponds to an aggregate result is left aligned within the cell. Is there a way to make all of the aggregate results right aligned?
  2. Answer
    Boris
    Admin
    Boris avatar
    276 posts

    Posted 22 Aug 2014 Link to this post

    Hello Robert,

    A possible way to right align the result text of the aggregate functions is to redefine the Footer property of the GridViewColumn. In order to affect how each aggregate result is displayed, you will need to use the AggregateResultsList and define a new DataTemplate for its ItemTemplate property. For example you can define a TextBlock and set its TextAlignment property to "Right":

    <telerik:GridViewDataColumn.Footer>                    
        <telerik:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" >
            <ItemsControl.ItemTemplate>
                <DataTemplate>                                     
                    <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" TextAlignment="Right" />                                     
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </telerik:AggregateResultsList>                    
    </telerik:GridViewDataColumn.Footer>

    I attached a sample project that demonstrates the suggested approach.

    Please examine it and let us know how it goes.

    Regards,
    Boris Penev
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Robert
    Robert avatar
    23 posts
    Member since:
    Oct 2011

    Posted 22 Aug 2014 in reply to Boris Link to this post

    Thanks, that works. Is there a reason that that's not the default functionality of setting FooterTextAlignment = TextAlignment.Right?
  5. Boris
    Admin
    Boris avatar
    276 posts

    Posted 22 Aug 2014 Link to this post

    Hi Robert,

    In general the setting the FooterTextAlignment property of the GridViewColumn to TextAlignment.Right is meant to only move to the right the control containing the aggregate functions and not its content. The aggregate result is displayed via TextBlock and its TextAlignment property by default is set to "TextAlignment.Left".

    I hope this helps.

    Regards,
    Boris Penev
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top