Skip to main content
A newer version of this page is available. .

Optimized Mode and Data Binding API

  • 3 minutes to read

The PivotGrid Optimized mode improves performance and provides an extended set of aggregatons and window functions. It allows you to use Data Binding API for PivotGrid fields.

The key concept of the Data Binding API is the data binding source. The Data Binding API does not divide PivotGrid fields into bound and unbound. All fields have the DataBinding property. All functionality related to calculations are encapsulated into the data binding source - the DataBindingBase descendant that is assigned to the field’s DataBinding property.

The bound field gets its data from a data source column. In the Optimized mode the bound field is a field whose DataBinding property is set to the DataSourceColumnBinding instance.

The former unbound fields in Optimized mode are fields whose DataBinding property is set to an instance of the class that specifies how the field gets its data. A field may get data from calculations (ExpressionDataBinding class), specific window calculations (RunningTotalBinding, MovingCalculationBinding etc.), or from a window calculation specified by an expression (WindowExpressionBinding class).

Note

The Data Binding API is in effect only in the Optimized mode. Other calculation engines ignore the DataBinding property.

You can use the Migrate to Optimized Mode command in the PivotGrid’s smart tag menu to invoke a pop-up window that helps you to migrate to Optimized mode.

This example demonstrates how to use the PivotGrid’s Data Binding API in Optimized mode.

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

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