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

Simple PivotGrid where cells show record count

3 Answers 70 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Ray
Top achievements
Rank 1
Ray asked on 03 Aug 2015, 03:28 PM

Hi,

Telerik UI for ASP.NET AJAX 2015.2.623

IE10

Visual Studion 2013

 

 I am new to the PivotGrid and can't seem to figure out this simple thing.  My SQLDataSource returns a list of valves.  2 of the columns are "Valve Size" and "Valve Type".  I have a sinple PivotGrid with a row field of "Valve Size" and a column field of "Valve Type":

    <telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" DataSourceID="sds_ValvesBuiltByDay">
        <Fields>
            <telerik:PivotGridColumnField DataField="Valve Type"></telerik:PivotGridColumnField>
            <telerik:PivotGridRowField DataField="Valve Size"></telerik:PivotGridRowField>
        </Fields>
    </telerik:RadPivotGrid>

When the page loads, there are rows for each size returned and columns for tech type but the individual cells in the grid are empty.

(See attached screenshot.  The RadGrid below the PivotGrid displays the same data from the same SQL data source)

I want each cell to show the count of records for that size and type combination.

This is probably very simple but I have not found a way to do it.

Please tell me what I am doing wrong. 

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 06 Aug 2015, 07:31 AM
Hello Ray,

You should add a PivotGridAggregateField to complete the picture. I believe the following post will prove very helpful if you are getting started with the pivot grid:
http://www.telerik.com/blogs/aspnet-pivot-table-made-easy

Looking forward to your reply.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Ray
Top achievements
Rank 1
answered on 13 Aug 2015, 05:50 PM

Hi Eyup,

Thanks for the reply!  I added the aggregate field as you said:

    <telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" DataSourceID="sds_ValvesBuiltByDay" OnCellDataBound="RadPivotGrid1_CellDataBound" Width="800px">
        <Fields>
            <telerik:PivotGridColumnField DataField="Valve Type"></telerik:PivotGridColumnField>
            <telerik:PivotGridRowField DataField="Valve Size"></telerik:PivotGridRowField>
            <telerik:PivotGridAggregateField DataField="Count" DataFormatString="{0:G}"></telerik:PivotGridAggregateField>
        </Fields>
    </telerik:RadPivotGrid>

But the numbers still don't show up.  In the article you posted, I don't see any additional steps that I missed.  What did I do wrong?

Please see the attached screenshot...

Just to make sure that I have described what I'm trying to do:

The aggregate numbers that I'm trying to display in each cell is the number of valves that are of that valve type (the column) and that valve size (the row).

Thanks,

 Ray

0
Eyup
Telerik team
answered on 18 Aug 2015, 09:48 AM
Hello Ray,

The DataField property should be set to some actual Field from your database. The property that is missing is Aggregate:
<telerik:PivotGridAggregateField DataField="ProductionOrder" Aggregate="Count">

That should do the trick. Please make the suggested modification and let me know about the result.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
PivotGrid
Asked by
Ray
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Ray
Top achievements
Rank 1
Share this question
or