Skip to main content
A newer version of this page is available. .
Tag

PivotGridFieldBase.UnboundExpression Property

Gets or sets an expression used to evaluate the current unbound field’s values.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v17.2.Core.dll

Declaration

[DefaultValue("")]
[XtraSerializableProperty]
public string UnboundExpression { get; set; }

Property Value

Type Default Description
String

String.Empty

A String that specifies an expression used to evaluate the current unbound field’s values.

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

When changing the UnboundExpression property, the 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 supply it with data using the PivotGridField.UnboundExpression property. In this example, extended price values are calculated according to the following expression: [Quantity] * [UnitPrice] * (1 - [Discount])

using DevExpress.XtraPivotGrid;

public Form1() {
    // ... 
            PivotGridField fieldExtendedPrice = new PivotGridField() { Caption = "Extended Price", Area = PivotArea.DataArea };

            fieldExtendedPrice.UnboundFieldName = "fieldExtendedPrice";
            fieldExtendedPrice.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
            fieldExtendedPrice.UnboundExpression = "[" + fieldQuantity.ExpressionFieldName + "] * [" +
                 fieldUnitPrice.ExpressionFieldName + "] * (1 - [" +
                 fieldDiscount.ExpressionFieldName + "])";

            pivotGridControl1.Fields.Add(fieldExtendedPrice);
}
See Also