how to template Grand Total line?

7 posts, 0 answers
  1. atran
    atran avatar
    12 posts
    Member since:
    Feb 2010

    Posted 24 Feb 2014 Link to this post

    I would like to re template the Grand Total line so that i could have 2 custom totals for each column.  Please see the attached image. 
  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 26 Feb 2014 Link to this post

    Hello,

    GrandTotals show the aggregated value of all cells above them and they are not designed to show two values. However there are two options that you can use:
    1) Use CellTemplateSelector and apply different template for the GrandTotal. In this case you will have to calculate and set the second value.
    2) Hide GrandTotal row and use two Calculated Items - one that will aggregate all values (similar to GrandTotal) and one for your Net value. This way you will have two rows, but the values will be calculated by RadPivotGrid and there will be no need of manual calculation from your side. You can find more information about CalculatedItems in our online help.

    We've prepared a sample project, that demonstrates both of the above approaches. Please give it a try and inform us in case you have any problems or concerns. 

    Regards,
    Rosen Vladimirov
    Telerik
  3. UI for WPF is Visual Studio 2017 Ready
  4. atran
    atran avatar
    12 posts
    Member since:
    Feb 2010

    Posted 12 Mar 2014 Link to this post

    please remove Grand Total.jpg from this post.
  5. atran
    atran avatar
    12 posts
    Member since:
    Feb 2010

    Posted 12 Mar 2014 in reply to Rosen Vladimirov Link to this post

    Option #1 sounds great for me.   
    "Use CellTemplateSelector and apply different template for the GrandTotal. In this case you will have to calculate and set the second value."

    How to set the second value?
    <template:CellTemplateSelector x:Key="CellTemplateSelector">
    <template:CellTemplateSelector.GrandTotalTemplate>
    <DataTemplate>
    <Border BorderThickness="1 1 0 0" BorderBrush="LightGray" Background="Transparent">
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height="*"/>
    <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <TextBlock Background="Transparent" FontWeight="Bold"
    Text="{Binding Data}"
    Foreground="{Binding Data, Converter={StaticResource ForegroundConverter}}"
    Margin="5"
    VerticalAlignment="Center"
    HorizontalAlignment="Right"/>

    <TextBlock Background="Transparent"
    Grid.Row="1"
    Text="??????"
    Margin="5"
    VerticalAlignment="Center"
    HorizontalAlignment="Right"/>
    </Grid>

    </Border>
    </DataTemplate>
    </template:CellTemplateSelector.GrandTotalTemplate>
    </template:CellTemplateSelector>
  6. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 14 Mar 2014 Link to this post

    Hello Andy,

    Changing the CellTemplate will require static data, you have to set it directly in the Text or you can try finding the TextBlock in the CellTemplateSelector and calculate the value in it. Of course, this is not a reliable solution when you have dynamic calculations, so we strongly recommend you to take a look at the second approach. I've prepared a sample project with two CalculatedItems and several CellTemplates and HeaderTemplates, so the calculated items will look like GrandTotals. Please give it a try and inform us in case you have any problems or concerns.

    Hope this helps.

    Regards,
    Rosen Vladimirov
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  7. atran
    atran avatar
    12 posts
    Member since:
    Feb 2010

    Posted 17 Mar 2014 in reply to Rosen Vladimirov Link to this post

    Hi Vladimirov,
        Please provide a sample code of finding the textblock in the celltemplateselect.  Which event should I place the code in? 
  8. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 19 Mar 2014 Link to this post

    Hello Andy,

    The best approach is to use Converter for the Text of the second TextBlock and return the value you want to show. I've modified my project in order to show you how to achieve this. Could you give it a try and inform us if it works for you?

    I'm looking forward to hearing from you.

    Regards,
    Rosen Vladimirov
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready