All docs
V20.2
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Data Binding API

  • 3 minutes to read

The Optimized Calculation mode uses the Data Binding API that provides a set of Intermediate Level Aggregations, and Calculations.

The DataBindingBase descendant is assigned to the field's DataBinding property. The Data Binding API does not divide PivotGrid fields into bound and unbound. The field's DataBinding property defines how the Pivot Grid field gets data.

  • The fields previously named bound get their data from a data source column. In Optimized mode, the bound field's DataBinding property is set to the DataSourceColumnBinding instance.

  • Former unbound fields use the DataBinding property to specify how the field gets its data. Bind the DataBinding property to an instance of the class that relates to the corresponding calculation. A field can get data from calculations (the ExpressionDataBinding class), specific window calculations (RunningTotalBinding, MovingCalculationBinding etc.), or from a window calculation specified by an expression (the WindowExpressionBinding class).

Use the field's Name property to identify the field in the WindowExpressionBinding.Expression and ExpressionDataBinding.Expression properties. The field's SummaryType property is not in effect.

The following table contains Data Binding API members:

WinForms WPF ASP.NET
DevExpress.XtraPivotGrid.RankBinding DevExpress.Xpf.PivotGrid.RankBinding DevExpress.Web.ASPxPivotGrid.RankBinding
DevExpress.XtraPivotGrid.MovingCalculationBinding DevExpress.Xpf.PivotGrid.MovingCalculationBinding DevExpress.Web.ASPxPivotGrid.MovingCalculationBinding
DevExpress.XtraPivotGrid.DifferenceBinding DevExpress.Xpf.PivotGrid.DifferenceBinding DevExpress.Web.ASPxPivotGrid.DifferenceBinding
DevExpress.XtraPivotGrid.DataSourceColumnBinding DevExpress.Xpf.PivotGrid.DataSourceColumnBinding DevExpress.Web.ASPxPivotGrid.DataSourceColumnBinding
DevExpress.XtraPivotGrid.PercentOfTotalBinding DevExpress.Xpf.PivotGrid.PercentOfTotalBinding DevExpress.Web.ASPxPivotGrid.PercentOfTotalBinding
DevExpress.XtraPivotGrid.ExpressionDataBinding DevExpress.Xpf.PivotGrid.ExpressionDataBinding DevExpress.Web.ASPxPivotGrid.ExpressionDataBinding
DevExpress.XtraPivotGrid.RunningTotalBinding DevExpress.Xpf.PivotGrid.RunningTotalBinding DevExpress.Web.ASPxPivotGrid.RunningTotalBinding
DevExpress.XtraPivotGrid.WindowExpressionBinding DevExpress.Xpf.PivotGrid.WindowExpressionBinding DevExpress.Web.ASPxPivotGrid.WindowExpressionBinding

The code snippet below demonstrates how to use the Data Binding API to calculate running totals.

NOTE

The complete sample project is available in the DevExpress Demo Center: Code Examples - Optimized Mode - Field Calculation Bindings module in the XtraPivotGrid MainDemo.

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 of the column.
fieldProductAmountRunningTotal.DataBinding = new RunningTotalBinding() {
    Source = productAmountBinding,
    PartitioningCriteria = CalculationPartitioningCriteria.ColumnValue,
    SummaryType = PivotSummaryType.Sum
};

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

Examples

See Also