Telerik blogs
The beta version of RadPivotGrid for WinForms is out, stacked and packed with a bunch of useful features you shouldn’t miss. Although there is still some time to go for the official release, the range of functionality available in beta phase, can help you achieve many of your pivotal scenarios with ease and we encourage you to give it a try. Below follows a list of RadPivotGrid’s features you get “out of the box”:
  1. Advanced design-time Property Builder
  2. PivotFieldList
  3. Filtering
  4. Layouts
  5. Totals Position
  6. Aggregates Position
  7. ScreenTips
  8. Range Grouping
  9. Cell Formatting
  10. Printing Support
  11. Integration with RadChartView

Advanced design-time Property Builder

To start RadPivotGrid off on your application, you should first set it up. Doing that from a lengthy list of properties would waste your time. In order to save you time and efforts, we decided that such a complex control should be supported by a powerful designer that allows for easy setup and customization. Meet our Property Builder:

PivotGrid Property Builder

This tool will greatly enhance the speed by which you set up a PivotGrid thanks to the user experience and interaction that were taken in mind while developing that tool. Internally, part of its functionality is powered by the PivotFieldList that I am going to cover below. 

PivotFieldList

Similar to the Excel PivotTable Field List, this component will make the life of the end-user as easy as a child game. Thanks to the drag and drop capabilities, checked listbox, context menus and advanced dialogs the end-user can set up a PivotGrid as 1-2-3. 

RadPivotGrid for WinForms PivotFieldList

All you need to associate a RadPivotFieldList control with RadPivotGrid is to set the AssocatedPivotGrid property of the fieldlist to the grid:

this.radPivotFieldList1.AssociatedPivotGrid = this.radPivotGrid1;

Filtering

RadPivotGrid allows you to add filter conditions which describe which items from the data source should be included in the report. These filters are called Report Filters. Report filtering occurs before the aggregated information is calculated. This type of filtering comes in handy when you would like to see a report that contains only records sharing a common field value, for example a sales report only for a specified country. The end-user can add a report filter by a simple drag and drop operation of the description item. Additionally, using the filter button of the filter descriptor item, the end-user can apply different filter conditions. This can be achieved by either selecting/deselecting items from the list box or by using one of the well-known filtering functions (Equals, Contains, Between, etc.). Group Filters on the other hand, can help with filtering a dataset after the aggregated information is calculated. Similar to the Report Filters, Group Filters can be arranged by a drag and drop operation and the end-user can apply filter conditions via the options given by the filter button’s context menu.

RadPivotGrid for WinForms Report Filter
Report Filtering

RadPivotGrid for WinForms Group Filtering
Group Filtering

From a developer’s perspective, this is how you can set report filter:

this.radPivotGrid1.ShowFilterArea = true;
 
PropertyFilterDescription description = newPropertyFilterDescription();
ComparisonCondition condition = newComparisonCondition();
 
condition.Condition = Comparison.Equals;
condition.Than = "UK";
 
description.PropertyName = "ShipCountry";
description.Condition = condition;
description.CustomName = "Country";
 
this.radPivotGrid1.FilterDescriptions.Add(description);

And this is how you can set a group filter:

PropertyGroupDescriptionBase description = (PropertyGroupDescriptionBase)this.radPivotGrid1.RowGroupDescriptions[0];
LabelGroupFilter filter = newLabelGroupFilter();
ComparisonCondition condition = newComparisonCondition();
 
condition.Condition = Comparison.Equals;
condition.Than = "UK";
 
filter.Condition = condition;
description.GroupFilter = filter;

Layouts

RadPivotGrid supports two types of layouts – Tabular and Compact. The Tabular layout displays each field in a separate box – for row descriptions in a separate column and for column descriptions in a separate row. The compact layout nests the field descriptions columns/rows in one common box to optimize space which can be useful in any scenario requiring usage of a big number of fields. The layout mode of the row headers is not coupled with the layout of the column headers. You can set the layout of the column headers via the ColumnHeadersLayout property, while for the row headers this is RowHeadersLayout. Setting both to PivotLayout.Tabular will produce this result:

RadPivotGrid for WinForms Tabular Layout

And here is how the Compact looks like thanks to the PivotLayout.Compact setting:

RadPivotGrid for WinForms Compact Layout

Totals Position

The position of the row\column sub and grand totals can be determined by these properties:

this.pivot.ColumnGrandTotalsPosition = TotalsPos.First;
this.pivot.ColumnsSubTotalsPosition = TotalsPos.First;
  
this.pivot.RowGrandTotalsPosition = TotalsPos.Last;
this.pivot.RowsSubTotalsPosition = TotalsPos.First;
      
They can be set to TotalsPos.First and TotalsPos.Last. As the name of the values imply, totals can be shown either at the end or at the beginning of the aggregated data. The availability of four different properties allows for setting the position of each type of total separately.

RadPivotGrid for WinForms Totals Position

Aggregates Position

End-users can define whether the aggregates should be located under the column or row groups. They can also set the position in the context of the order of row\column groups. All this can happen by a single drag-drop operation:

RadPivotGrid for WinForms DragDrop Aggregates

In code you can set whether the aggregates should be under the column or row groups by using the AggregatesPosition property. As to the position in the order of row\column groups (or the level of the aggregates), you can set it by using the AggregatesLevel property. Here are a few examples :

RadPivotGrid for WinForms Column Aggregates
AggregatesPosition = PivotAxis.Columns

RadPivotGrid for WinForms Row Aggregate Level 1
AggregatesPosition = PivotAxis.Rows, AggregatesLevel = 1

RadPivotGrid for WinForms Row Aggregates
AggregatesPosition = PivotAxis.Rows, AggregatesLevel = 2

ScreenTips

By default, when the end-user hovers a cell in RadPivotGrid, a screentip gets shown providing a summary of the cell – its value, row descriptions and column descriptions under which it appears:

RadPivotGrid for WinForms ScreenTips

You can prevent the screentip from showing by setting the AllowDefaultScreenTips
to false:

this.radPivotGrid1.AllowDefaultScreenTips = false;

Range Grouping

In addition to the standard grouping that groups by the unique values of a specific data field, RadPivotGrid allows for range grouping that defines groups based on a certain range of values. For example, you can group all dates from a datetime data field by month and then create a group description that groups the data in the pivot by month. Here is how we can group values in code:

this.radPivotGrid1.RowGroupDescriptions.Add(newDateTimeGroupDescription() { PropertyName = "OrderDate", Step = DateTimeStep.Month, GroupComparer = newGroupNameComparer() , CustomName = "Month"});

And here is the difference that the range grouping makes:

RadPivotGrid for WinForms Range Grouping

Cell Formatting

The well-known CellFormatting event, available to RadGridView, is available to RadPivotGrid as well. Thanks to it you can achieve various style effects to certain parts of the displayed data. For example, the following snippet will colorize the rows for August and November in different in Lime and Yellow:

void radPivotGrid1_CellFormatting(object sender, PivotCellEventArgs e)
{
     if (e.CellElement.Row.Name == "August"&& !e.CellElement.IsInGrandTotalColumn)
     {
          e.CellElement.BackColor = Color.Lime;
          e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     }
     elseif (e.CellElement.Row.Name == "November"&& !e.CellElement.IsInGrandTotalColumn)
     {
          e.CellElement.BackColor = Color.Yellow;
          e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
     }
     else
     {
          e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
          e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
     }
}

RadPivotGrid for WinForms Cell Formatting

Printing Support

Printing is yet another critical feature for every data management control. Printing for RadPivotGrid exposes the same well-known common functionality available to RadGridView and RadScheduler – setting paper size, watermark, etc. The end-user can also set Pivot-specific printing properties such as font and color to the group descriptions and aggregates. Thanks to the PrintElementFormatting and PrintElementPaint events you can put a custom touch to the way the data cells will be printed out. Here is how you can easily trigger the Print Preview dialog:

this.radPivotGrid1.PrintPreview();

PivotGrid Print Preview

Integration with RadChartView

Getting lost in numbers and the totals does not help much? Native integration with RadChartView will allow the end-user to visualize graphically each selection made in RadPivotGrid, thus easily exploring hidden trends in the data and unveiling critical business insights using charts:

PivotGrid Integration with RadChartView


You can associate RadChartView with RadPivotGrid by simply setting the DataSource of the chart to the grid:

this.radChartView1.DataSource = this.radPivotGrid1;
So, lots of stuff, huh? I tried to make this article as brief as possible just to outline the basics of how powerful RadPivotGrid is. However, I couldn’t pack it all in detail, so this blog post will be followed by additional ones that will demonstrate how you can fully unleash the power of RadPivotGrid for WinForms.

Stay tuned!

Download RadControls for WinForms by Telerik


About the Author

Nikolay Diyanov

Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

Find him on Twitter @n_diyanov or on LinkedIn.

Related Posts

Comments

Comments are disabled in preview mode.