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

DifferenceBinding Class

Defines the difference calculation between values across a window.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v20.2.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public class DifferenceBinding :
    DifferenceBindingBase

Remarks

To bind a PivotGrid field to the result of the difference window calculations, do the following:

  1. Create an instance of the DifferenceBinding class with the Source property set to the DataBindingBase descendant instance.
  2. Specify the window frame and calculation settings.
  3. Assign the DifferenceBinding instance to the PivotGridField.DataBinding property.

Example

The following code snippet illustrates the use of the Data Binding API:

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 fieldProductAmountDifference = new PivotGridField()
{
    Area = PivotArea.DataArea,
    Caption = "Difference",
    Name = "fDifference"

};
DataSourceColumnBinding productAmountBinding = new DataSourceColumnBinding("ProductAmount");
//Bind a field to a column in the data source.
fieldProductAmount.DataBinding = productAmountBinding;
//Calculate a difference between the preceding and current value in the column.
fieldProductAmountDifference.DataBinding = new DifferenceBinding()
{
    Source = productAmountBinding,
    PartitioningCriteria = CalculationPartitioningCriteria.ColumnValue,
    Target = DifferenceTarget.Previous,
    DifferenceType = DifferenceType.Absolute
};
pivotGridControl.Fields.AddRange(new PivotGridField[] {
    fieldProductAmount,
    fieldProductAmountDifference
});
See Also