Skip to main content
All docs
V24.2

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:

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.

  1. Click the Pivot Grid’s smart tag icon and then click Designer… to invoke the ASPxPivotGrid Designer.

  2. Add new field to the Data Header Area.

  3. Set the field’s DataBinding property to Running Total.

  4. Set the Source property to obtain data to calculate.

  5. Specify Direction, SummaryType, and PartitioningCriteria.

The image below illustrates settings specified for the Running Total binding:

Create running total field at design time

Runtime

The example below shows how to use RunningTotalBinding to display a cumulative total of the Extended Price field values.

View Example: Pivot Grid Optimized Mode - Field Calculation Data Binding

  1. Create an instance of the RunningTotalBinding class with the Source property set to a DataBindingBase descendant instance.
  2. Specify the window frame and summary type.
  3. 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>