PivotGridField.UnboundExpression Property
Gets or sets an expression used to evaluate values for the current unbound field.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v21.1.dll
NuGet Packages: DevExpress.Win.Design, DevExpress.Win.PivotGrid
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A String that specifies an expression used to evaluate values for the current field. |
Remarks
You can create an unbound field by setting the PivotGridFieldBase.UnboundType property to a specific data type. The PivotGridFieldBase.FieldName property must be set to a unique value that does not refer to any field in the pivot grid’s data source. Unbound fields can be populated manually via the PivotGridControl.CustomUnboundFieldData event, or by specifying an expression via the UnboundExpression property, used to evaluate values for this field. The Expressions section describes the syntax for creating expressions. To refer to a field when specifying an unbound expression in code, use the PivotGridFieldBase.ExpressionFieldName property. The PivotGridOptionsData.DataFieldUnboundExpressionMode property allows you to specify whether the expressions are calculated, based on the data source records, or summary values.
Note
When the PivotGridOptionsData.DataFieldUnboundExpressionMode property is set to DataFieldUnboundExpressionMode.UseSummaryValues, the PivotGridFieldBase.FieldName and PivotGridFieldBase.Name properties cannot be used in unbound expressions to refer to fields.
If the PivotGridFieldOptionsEx.ShowUnboundExpressionMenu option is enabled, an end-user can edit a field’s expression via the Expression Editor at runtime. See PivotGridFieldOptionsEx.ShowUnboundExpressionMenu, for more information.
When changing the UnboundExpression property, the PivotGridControl.FieldUnboundExpressionChanged event fires.
To learn more about unbound fields, see Unbound Fields.
Example
The following code snippet demonstrates how to create an unbound field in code and use the PivotGridField.UnboundExpression
property to supply data.
In this example, extended price values are calculated as follows:
[Quantity] * [UnitPrice] * (1 - [Discount]).
Pivot Grid field names are obtained using the PivotGridFieldBase.ExpressionFieldName property.
PivotGridField fieldExtendedPrice = new PivotGridField() { Caption = "Extended Price", Area = PivotArea.DataArea };
fieldExtendedPrice.UnboundFieldName = "fieldExtendedPrice";
fieldExtendedPrice.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
fieldExtendedPrice.UnboundExpression = string.Format("[{0}] * [{1}] * (1 - [{2}])",
fieldQuantity.ExpressionFieldName, fieldUnitPrice.ExpressionFieldName, fieldDiscount.ExpressionFieldName);
pivotGridControl1.Fields.Add(fieldExtendedPrice);
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the UnboundExpression 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.