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:
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
- WinForms: Field Calculation Bindings module in the XtraPivotGrid MainDemo
- WPF: Pivot Grid Optimized Mode - Field Calculation Data Binding
- ASP.NET Web Forms: How to Implement Custom Summary