PivotGridFieldBase.UnboundType Property
Gets or sets the field's data type and binding mode.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.PivotGrid.v19.1.Core.dll
Declaration
[DefaultValue(UnboundColumnType.Bound)]
[XtraSerializableProperty]
public UnboundColumnType UnboundType { get; set; }
<DefaultValue(UnboundColumnType.Bound)>
<XtraSerializableProperty>
Public Property UnboundType As UnboundColumnType
Property Value
Type | Default | Description |
---|---|---|
UnboundColumnType | Bound |
A UnboundColumnType enumeration value representing the field's data type and binding mode. |
Remarks
PivotGridControl supports unbound fields. These fields are not bound to any field in the control's data source specified by the PivotGridControl.DataSource and PivotGridControl.DataMember properties.
To provide data for unbound fields, use one of the following approaches
- calculate unbound field values by specifying an expression (the PivotGridFieldBase.UnboundExpression property);
- handle the PivotGridControl.CustomUnboundFieldData event.
To make a field unbound, change its UnboundType property from UnboundColumnType.Bound to the required value type (UnboundColumnType.String, UnboundColumnType.Decimal, etc.).
If the field's UnboundType property is set to UnboundColumnType.Bound, it's assumed that this field is bound to a specific field in the data source specified by the PivotGridFieldBase.FieldName property.
NOTE
The PivotGridFieldBase.FieldName property value of an unbound field must be unique, and not match any field name in the underlying data source. Otherwise, it is treated differently in Legacy (PivotDataProcessingEngine.Legacy) and LegacyOptimized (PivotDataProcessingEngine.LegacyOptimized) modes - matching field names indicate that the field is bound in the Legacy mode.
Examples
The code snippet below demonstrates how to create an unbound field in code and supply it with data using the PivotGridControl.CustomUnboundFieldData event. In this example, extended price values are calculated manually using the formula UnitPrice * Quantity * (1-Discount).
using DevExpress.XtraPivotGrid;
// ...
public Form1() {
// ...
pivotGridControl1.CustomUnboundFieldData += PivotGridControl1_CustomUnboundFieldData;
PivotGridField fieldExtendedPrice = new PivotGridField() { Caption = "Extended Price", Area = PivotArea.DataArea };
fieldExtendedPrice.UnboundFieldName = "fieldExtendedPrice";
fieldExtendedPrice.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
pivotGridControl1.Fields.Add(fieldExtendedPrice);
}
private void PivotGridControl1_CustomUnboundFieldData(object sender, CustomFieldDataEventArgs e) {
if (e.Field.UnboundFieldName == "fieldExtendedPrice") {
decimal unitPrice = Convert.ToDecimal(e.GetListSourceColumnValue(fieldUnitPrice.ExpressionFieldName));
int qty = Convert.ToInt32(e.GetListSourceColumnValue(fieldQuantity.ExpressionFieldName));
decimal discount = Convert.ToDecimal(e.GetListSourceColumnValue(fieldDiscount.ExpressionFieldName));
e.Value = unitPrice * qty * (1 - discount);
}
}
}
}