PivotGridFieldBase.UnboundType Property
Gets or sets the field’s data type and binding mode.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.PivotGrid.v24.1.Core.dll
NuGet Packages: DevExpress.PivotGrid.Core, DevExpress.Win.Navigation
Declaration
[PivotAPIMemberCategory(APICategory.LegacyBinding)]
[PivotAPIMemberCategory(APICategory.RelationalSource)]
[XtraSerializableProperty]
public UnboundColumnType UnboundType { get; set; }
Property Value
Type | Description |
---|---|
UnboundColumnType | A UnboundColumnType enumeration value representing the field’s data type and binding mode. |
Available values:
Name | Description |
---|---|
Bound | Indicates that the column is bound to a field in the control’s underlying data source. The type of data this column contains is determined by the bound field. |
Integer | Indicates that the column is unbound and it contains integer values (the Int32 type). |
Decimal | Indicates that the column is unbound and it contains decimal values (the Decimal type). |
DateTime | Indicates that the column is unbound and it contains date/time values (the DateTime type). |
String | Indicates that the column is unbound and it contains string values (the String type). |
Boolean | Indicates that the column is unbound and it contains Boolean values (the Boolean type). |
Object | Indicates that the column is unbound and it contains values of any type. A TextEdit editor is assigned for the in-place editing of such a column. |
Remarks
Note
This member is not supported in Optimized, OLAP, and Server modes. Use ExpressionDataBinding/OlAPExpressionBinding instead.
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.
Example
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);
}
}
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the UnboundType property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.