Skip to content

This example shows how to add unbound fields in Pivot Grid for Web Forms.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/web-forms-pivot-grid-add-unbound-fields

Repository files navigation

Pivot Grid for Web Forms - How to Add Calculated Fields

The following example shows how to add calculated fields to the ASPxPivotGrid. Calculated fields display the result of calculated expressions. Each calculated field has a binding expression that can be a formula or aggregate function.

To supply a calculated field with data, use the ExpressionDataBinding class, and pass to the Expression property a string expression to calculate.

In this example, the DiscountAmount and PriceWithDiscount pivot grid's fields are calculated fields:

<dx:PivotGridField ID="fieldDiscountAmount" Area="DataArea"
        AreaIndex="2"
        Caption="Discount Amount">
    <DataBindingSerializable>
        <dx:ExpressionDataBinding Expression="[ExtendedPrice]*[Discount]" />
    </DataBindingSerializable>
</dx:PivotGridField>
<dx:PivotGridField ID="fieldPriceWithDiscount" Area="DataArea"
        AreaIndex="3" UnboundType="Decimal"
        FieldName="PriceWithDiscount"
        Caption="Price with Discount">
    <DataBindingSerializable>
        <dx:ExpressionDataBinding Expression="[fieldExtendedPrice] * (1 - [fieldDiscount])" />
    </DataBindingSerializable>
</dx:PivotGridField>

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)