Transform Tables into Slice-and-Dice Reports
As you browse these web pages and begin using the ASPxPivotGrid within your applications, you will discover that when it comes to ease-of-use and flexibility, the ASPxPivotGrid has no equal in the marketplace. Fact is that when it comes to data analysis and data mining, the ASPxPivotGrid is the only product that empowers your end-users to solve their business needs without being forced to use cumbersome and overly complex reporting solutions.
To demonstrate just how easy it is to implement the ASPxPivotGrid, we'll quickly describe the benefits of a pivot layout, guide you through the basics of creating pivot reports and describe just a few of the end-user options available out-of-the-box.
This page is broken down into the following main sections:
A video tutorial showing how to get started with the ASPxPivotGrid is available in the DevExpress Analytics Blog.
Transform Plain-Table Data into a Pivot Report
For demonstration purposes, let's consider a car sales database with the following structure: 
You can easily construct a query that will merge the information in all the tables into a single record set. If each record in the Orders table represents a single-car purchase, the total number of fields in the query's results will match the total number of cars sold. Summing by the Price field will generate sales totals. 
Based on the data contained in these tables, let's assume your customer requests that you display the total number of cars sold on any given day, by individual model - and how sales of these models have changed over time. To solve this business requirement and demonstrate the power of the ASPxPivotGrid, we'll go ahead and bind the PivotGrid to the record set and create the fields which correspond to the underlying data source.

To construct the appropriate report layout, you simply need to place fields to the correct region. To do this, use the field's Area property. As such, if you need to see a cross-report of sales by dates and models, set the Area property of the OrderDate and Model fields to 'ColumnArea' and 'RowArea', respectively. To display the sum of sales for each date and model intersection, locate the Price field to the data area by settings its Area property to 'DataArea'. The image below shows the resulting report. Instead of a hard to read table of data with numerous records that have to be scrolled vertically and then analyzed (a laborious process to say the least), your customer instead has a fully summarized and compact report at his fingertips.

End-users can freely drag field headers in the same manner as you do at design time. Just a few drag and drop operations can entirely change the report's layout. This allows end-users to analyze the source data in the way they want to, without you having to redo a single thing. Below are a few examples that have been generated by simply dragging the field headers between areas.
Use Multiple Data Fields in a Report
The previous example showed an extremely simple report with just a data field. This means that there is a single cell at each column/row intersection. But the ASPxPivotGrid lets you create reports which have an unlimited number of data fields. In addition to that, you and end-users have additional options for customizing the control's layout.
Let's add one more field to the control to display the number of cars sold. The only field in the previous example (Price) used the default summary type for numeric columns - sum. For the newly added field, you need to change the summary type to count. There are 9 different built-in summary types available within the ASPxPivotGrid.

Note: the ASPxPivotGrid does not limit you with these predefined summary types. You can implement a custom aggregate function by writing a CustomSummary event handler.
Now, when multiple fields are in the report, you can enable the Data header. Like any other header, you or end-users can drag it to different locations to fine-tune your report. This header lets you control which data to display first, whether to arrange data fields horizontally or vertically, etc. The content, size and availability of the Data header are controlled via the control's OptionsDataField property.

The following screenshots offer a glimpse into additional layouts that are just a drag and drop away from your users.
Adopt Any Data Using Manually Calculated Fields
Consider a more general case when the Orders table contains one more field - UnitsOnOrder. In this instance, the sales volume for each record is Price multiplied by UnitsOnOrder.

To display the sales volume in the ASPxPivotGrid, you can easily add a manually calculated field which will hold Price multiplied by UnitsOnOrder. To accomplish this task, you need to carry out three simple steps. Add a new field, set its UnboundType property to Decimal and write a two-line handler for the CustomUnboundFieldData event.
|
protected void ASPxPivotGrid1_CustomUnboundFieldData(object sender, CustomFieldDataEventArgs e) { if (e.Field.FieldName == "Sales") { e.Value = (decimal)e.GetListSourceColumnValue("Price") * (int)e.GetListSourceColumnValue("UnitsOnOrder"); } }
Protected Sub ASPxPivotGrid1_CustomUnboundFieldData(ByVal sender As Object, _ ByVal e As CustomFieldDataEventArgs) _ Handles ASPxPivotGrid1.CustomUnboundFieldData If e.Field.Name = "Sales" Then _ e.Value = e.GetListSourceColumnValue("Price") * _ e.GetListSourceColumnValue("UnitsOnOrder") End Sub
|
Now you can create a new report that will match the updated database structure. Simply drag the newly created Sales field to the data area and fine-tune your report by moving other headers to the desired locations. The following image shows a sample.

Show Trends Using the Built-in Summary Variation Feature
If the main aim of end-users is to analyze trends - see how values are changing with time or depending on other values - you will be glad to know that the ASPxPivotGrid offers you a built-in solution for this objective. You can trigger a single property to force cells to display differences rather than actual values. And there are two difference display modes available - absolute or percent.
Take a look at the next image for an example. Initially, there are two fields in the data area. They are bound to the same data field and thus display the same values. After you change one field's SummaryVariation property to Absolute, this field lets you see how sales were changing with time. Each cell displays the difference between its actual value and the value in the preceeding cell.

In the screenshot above, you see the variation displayed by dates. The obvious question is how can one change variation direction to display trends by sales person. This is possible by means of the Data header discussed earlier. End-users can drag it to the column area to display left-to-right trends or to the row area to display top-to-bottom trends. You can control this programmatically using the OptionsDataField.Area property even if the Data header is invisible.
Back to the Feature List
|