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

how to template Grand Total line?

6 Answers 167 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
atran
Top achievements
Rank 1
atran asked on 24 Feb 2014, 06:07 PM
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. 

6 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 26 Feb 2014, 04:32 PM
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
0
atran
Top achievements
Rank 1
answered on 12 Mar 2014, 05:00 PM
please remove Grand Total.jpg from this post.
0
atran
Top achievements
Rank 1
answered on 12 Mar 2014, 06:30 PM
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>
0
Rosen Vladimirov
Telerik team
answered on 14 Mar 2014, 11:21 AM
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.

 
0
atran
Top achievements
Rank 1
answered on 17 Mar 2014, 05:51 PM
Hi Vladimirov,
    Please provide a sample code of finding the textblock in the celltemplateselect.  Which event should I place the code in? 
0
Rosen Vladimirov
Telerik team
answered on 19 Mar 2014, 05:06 PM
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.

 
Tags
PivotGrid
Asked by
atran
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
atran
Top achievements
Rank 1
Share this question
or