PivotGridFieldBase.ExpressionFieldName Property

Gets the field's name in unbound expressions.

Namespace: DevExpress.XtraPivotGrid

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

Declaration

[Browsable(false)]
public string ExpressionFieldName { get; }
<Browsable(False)>
Public ReadOnly Property ExpressionFieldName As String

Property Value

Type Description
String

A String representing the field's name in unbound expressions.

Remarks

The examples below show how to create unbound fields in code and supply them with data using expressions. Note that the ExpressionFieldName property is utilized to use other fields within an expression.

  • Example 1

    The following code snippet demonstrates how to create an unbound field in code and supply this field with data using the PivotGridField.UnboundExpression property. In this example, full names are generated based on the first and last names stored in the underlying data source.

    using DevExpress.XtraPivotGrid;
    
    public Form1() {
        // ... 
                PivotGridField fieldFullName = new PivotGridField() { Caption = "Full Name", Area = PivotArea.RowArea };
    
                fieldFullName.UnboundFieldName = "fieldFullName";
                fieldFullName.UnboundType = DevExpress.Data.UnboundColumnType.String;
                fieldFullName.UnboundExpression = 
                    "[" + fieldFirstName1.ExpressionFieldName + "]" + 
                    "+" + "' '" + "+" +
                    "[" + fieldLastName1.ExpressionFieldName + "]";
    
                pivotGridControl1.Fields.Add(fieldFullName);
    }
    
  • Example 2

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