Bind Pivot Grid Fields to Window Calculations
- 2 minutes to read
The Pivot Grid uses the Binding API to bind Pivot Grid fields to data. You can use calculated expressions, data source columns, or window calculations as data binding sources.
The sections below describe how to bind a Pivot Grid field to a result of the window calculation in Optimized mode.
The following classes are supported:
- RunningTotalBinding
- DifferenceBinding
- RankBinding
- PercentOfTotalBinding
- MovingCalculationBinding
- WindowExpressionBinding
Design Time
The example below shows how to create a Pivot Grid field to display a cumulative total of the Extended Price
field values at design time.
Click the Pivot Grid’s smart tag icon and then click Designer… to invoke the ASPxPivotGrid Designer.
Add new field to the Data Header Area.
Set the field’s DataBinding property to
Running Total
.Set the Source property to obtain data to calculate.
Specify Direction, SummaryType, and PartitioningCriteria.
The image below illustrates settings specified for the Running Total binding:
Runtime
The example below shows how to use RunningTotalBinding
to display a cumulative total of the Extended Price
field values.
- Create an instance of the
RunningTotalBinding
class with theSource
property set to a DataBindingBase descendant instance. - Specify the window frame and summary type.
- Assign the
RunningTotalBinding
instance to the PivotGridFieldBase.DataBinding property.
<dx:PivotGridField ID="fieldRunningTotal" Area="DataArea" AreaIndex="4" Name="fieldRunningTotal" Caption="RunningTotal">
<DataBindingSerializable>
<dx:RunningTotalBinding SummaryType="Average" Direction="AcrossThenDown" PartitioningCriteria="ColumnValueAndRowParentValue">
<SourceSerializable>
<dx:DataSourceColumnBinding ColumnName="Extended Price" />
</SourceSerializable>
</dx:RunningTotalBinding>
</DataBindingSerializable>
<CellFormat FormatString ="c2" FormatType="Numeric"></CellFormat>
</dx:PivotGridField>