DataSourceColumnBinding Class
Defines a data binding to a source data column.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v24.2.dll
Declaration
Remarks
Pivot Grid uses the Binding API to bind Pivot Grid’s fields to data. DataSourceColumnBinding
allows you to bind a Pivot Grid’s field to a data column in the data source. The Pivot Grid’s field obtains its values from a field in the data source.
You can use DataSourceColumnBinding
in Optimized, Server, and OLAP data processing modes.
Examples
Optimized and Server Modes
Follow the steps below to bind a Pivot Grid’s field to the data source field in code:
- Create a
DataSourceColumnBinding
instance. - Set the DataSourceColumnBindingBase.ColumnName property to the name of the source data field.
- Assign the
DataSourceColumnBinding
object to the PivotGridFieldBase.DataBinding property.
The following code snippet illustrates how to create the Pivot Grid’s fieldProductAmount
field and bind it to the ProductAmount
source field:
PivotGridField fieldProductAmount = new PivotGridField() {
Area = PivotArea.DataArea,
Caption = "Product Sales",
Name = "fProductAmount"
};
DataSourceColumnBinding productAmountBinding = new DataSourceColumnBinding("ProductAmount");
//Bind a field to a column in the data source.
fieldProductAmount.DataBinding = productAmountBinding;
pivotGridControl.Fields.Add(fieldProductAmount);
OLAP Mode
Follow the steps below to bind a Pivot Grid’s field to a measure or dimension in code in OLAP mode:
Create a
DataSourceColumnBinding
instance.Specify the DataSourceColumnBindingBase.ColumnName property.
ColumnName
must specify the full name of the bound measure or dimension.For dimensions, the full name is composed of a dimension name, followed by a hierarchy name, followed by the name of a level(s). All names should be wrapped within square brackets and separated from one another with the dot symbol. Example: “[Customer].[Customer Geography].[Country]”.
For measures, the full name is composed of the “[Measures].” string followed by the measure name. Example: “[Measures].[Sales Amount]”.
Assign the
DataSourceColumnBinding
object to the PivotGridFieldBase.DataBinding property.
The following code snippet illustrates how to create the fieldCity
field and bind it to the City
dimension:
PivotGridField fieldCity = pivotGridControl1.Fields.Add("City", PivotArea.RowArea);
fieldCity.DataBinding = new DataSourceColumnBinding("[Customer].[City].[City]");
fieldCity.Name = "fieldCity";