corelibraries-devexpress-dot-xtrapivotgrid-dot-pivotgridfieldbase-84ea62ab.md
Gets or sets the field’s data type and binding mode.
Namespace : DevExpress.XtraPivotGrid
Assembly : DevExpress.PivotGrid.v25.2.Core.dll
NuGet Packages : DevExpress.PivotGrid.Core, DevExpress.Win.Navigation
[DefaultValue(UnboundColumnType.Bound)]
public UnboundColumnType UnboundType { get; set; }
<DefaultValue(UnboundColumnType.Bound)>
Public Property UnboundType As UnboundColumnType
| Type | Default | Description |
|---|---|---|
| UnboundColumnType | Bound |
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.
|
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
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.
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);
}
}
}
}
Imports DevExpress.XtraPivotGrid
' ...
Public Sub New()
' ...
AddHandler pivotGridControl1.CustomUnboundFieldData, AddressOf PivotGridControl1_CustomUnboundFieldData
Dim fieldExtendedPrice As New PivotGridField() With {.Caption = "Extended Price", .Area = PivotArea.DataArea}
fieldExtendedPrice.UnboundFieldName = "fieldExtendedPrice"
fieldExtendedPrice.UnboundType = DevExpress.Data.UnboundColumnType.Decimal
pivotGridControl1.Fields.Add(fieldExtendedPrice)
End Sub
Private Sub PivotGridControl1_CustomUnboundFieldData(ByVal sender As Object, ByVal e As CustomFieldDataEventArgs)
If e.Field.UnboundFieldName = "fieldExtendedPrice" Then
Dim unitPrice As Decimal = Convert.ToDecimal(e.GetListSourceColumnValue(fieldUnitPrice.ExpressionFieldName))
Dim qty As Integer = Convert.ToInt32(e.GetListSourceColumnValue(fieldQuantity.ExpressionFieldName))
Dim discount As Decimal = Convert.ToDecimal(e.GetListSourceColumnValue(fieldDiscount.ExpressionFieldName))
e.Value = unitPrice * qty * (1 - discount)
End If
End Sub
End Class
End Namespace
The following code snippet (auto-collected from DevExpress Examples) contains a reference 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.
fieldValueTotal.UnboundExpression = "Sum(Iif([Type]='Income', [Value], -[Value]))";
fieldValueTotal.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
fieldValueTotal.UnboundExpressionMode = UnboundExpressionMode.UseAggregateFunctions;
fieldValueTotal.UnboundExpression = "Sum(Iif([Type]='Income', [Value], -[Value]))"
fieldValueTotal.UnboundType = DevExpress.Data.UnboundColumnType.Decimal
fieldValueTotal.UnboundExpressionMode = UnboundExpressionMode.UseAggregateFunctions
See Also