Obelix
Obelix

Reputation: 708

Telerik PivotGrid column configuration

I'm currently working on a pivotgrid trying to build this according to a excel sheet specification excel example

The excel groups the data rows based on category a and category b. The columns are grouped by years.

The pivotgrid groups the data like follows: Pivotgrid render

The pivotgrid is configured like follows:

<Fields>
   <telerik:PivotGridRowField DataField="A" UniqueName="AColumn" Caption="A" >
   </telerik:PivotGridRowField>
   <telerik:PivotGridRowField DataField="B" UniqueName="BColumn" Caption="B">
   </telerik:PivotGridRowField>

   <telerik:PivotGridColumnField DataField="Year" UniqueName="YearColumn" Caption="Year">
   </telerik:PivotGridColumnField>
   <telerik:PivotGridColumnField DataField="Count" UniqueName="CountColumn" Caption="Count">
   </telerik:PivotGridColumnField>
   <telerik:PivotGridColumnField DataField="Figure" UniqueName="FigureColumn" Caption="Figure">
   </telerik:PivotGridColumnField>
</Fields>

How can I configure the grid in such a way that it doesn't group the data in the count and figure columns but groups the year columns?

The source data is like follows:

source data

All tips/tricks are welcome! I'm a bit stuck in the mud with this one.

Upvotes: 0

Views: 1925

Answers (1)

Obelix
Obelix

Reputation: 708

found the answer yesterday, it wasn't working because of an error in the Telerik PivotGrid (reported the error).

The code should be used as follows:

<Fields>
    <telerik:PivotGridRowField DataField="A" UniqueName="AColumn" Caption="A">
    </telerik:PivotGridRowField>
    <telerik:PivotGridRowField DataField="B" UniqueName="BColumn" Caption="B">
    </telerik:PivotGridRowField>

    <telerik:PivotGridColumnField DataField="Year" UniqueName="YearColumn" Caption="Year">
    </telerik:PivotGridColumnField>

    <telerik:PivotGridAggregateField DataField="Count" Aggregate="Sum" UniqueName="CountColumn" Caption="Count">                    
    </telerik:PivotGridAggregateField>
    <telerik:PivotGridAggregateField DataField="Figure" Aggregate="Sum" UniqueName="FigureColumn" Caption="Figure" DataFormatString="{0:C}">
    </telerik:PivotGridAggregateField>
</Fields>

Please note that you should NOT use AggregatesLevel="0" in the properties of the pivotgrid. this will present you witha null reference exception.

<telerik:RadPivotGrid ID="PivotGrid" runat="server" 
    AggregatesLevel="0">

</telerik:RadPivotGrid>

Upvotes: 1

Related Questions