Skip to main content
A newer version of this page is available. .
All docs
V22.1

Bind Pivot Grid Fields to Window Calculations

  • 2 minutes to read

The article describes how to use the Binding API to bind a Pivot Grid field to the result of the window calculation when the Pivot Grid uses the Optimized data processing engine.

Design Time

  1. Add a new field to the data area in any of the following ways:

    • Click ‘Run Designer’ in the PivotGrid’s smart tag menu. In the Pivot Grid Designer window, select the Fields page and click AddNewFieldButton or InsertNewFieldButton to add a new field.

    • Use the ‘Add Field to Data Area’ option in the PivotGrid’s smart tag. Then, you can specify its properties in the property grid or in the field’s smart tag menu.

  2. Set the field’s PivotGridFieldBase.DataBinding property to one of the following values:

  3. Specify calculation properties according to the set DataBinding value.

    For example, the image below illustrates settings specified for the Running Total binding:

    pivot-running-total-binding-design-time

Runtime

Run Demo: Field Calculation Bindings

The following example shows how to create the RunningTotalBinding calculation binding. The Pivot Grid binds the fieldProductAmountRunningTotal field to the result of the running total calculation.

  1. Create an instance of the RunningTotalBinding class with the Source property set to the DataBindingBase descendant’s instance.
  2. Specify the window frame and summary type.
  3. Assign the RunningTotalBinding instance to the PivotGridField.DataBinding property.
pivotGridControl.OptionsData.DataProcessingEngine = PivotDataProcessingEngine.Optimized;

PivotGridField fieldProductAmount = new PivotGridField() {
    Area = PivotArea.DataArea,
    Caption = "Product Sales",
    Name = "fProductAmount"
};

PivotGridField fieldProductAmountRunningTotal = new PivotGridField {
    Area = PivotArea.DataArea,
    Caption = "Running Total",
    Name = "fRunningTotal"
};

DataSourceColumnBinding productAmountBinding = new DataSourceColumnBinding("ProductAmount");
//Bind a field to a column in the data source.
fieldProductAmount.DataBinding = productAmountBinding;
//Calculate a running summary on the column.
fieldProductAmountRunningTotal.DataBinding = new RunningTotalBinding() {
    Source = productAmountBinding,
    PartitioningCriteria = CalculationPartitioningCriteria.ColumnValue,
    SummaryType = PivotSummaryType.Sum
};

pivotGridControl.Fields.AddRange(new PivotGridField[] {
    fieldProductAmount,
    fieldProductAmountRunningTotal,
});
See Also