PivotGridFieldBase.UnboundType Property

Gets or sets the field's data type and binding mode.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v20.1.Core.dll

Declaration

[DefaultValue(UnboundColumnType.Bound)]
[PropertyCategory(PropertyCategory.LegacyBinding)]
[PropertyCategory(PropertyCategory.RelationalSource)]
public UnboundColumnType UnboundType { get; set; }
<PropertyCategory(PropertyCategory.RelationalSource)>
<PropertyCategory(PropertyCategory.LegacyBinding)>
<DefaultValue(UnboundColumnType.Bound)>
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

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).

PivotGridContol.CustomUnboundFieldData_ex

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);
            }
        }
    }
}
See Also