Skip to main content

Field Groups

PivotGridControl provides the capability to arrange fields into groups. Fields which are grouped, cannot be separated by end-users by dragging one of them to a different area or hiding it to the customization form.

pivotgrid_groups

Field groups are stored within the PivotGridControl.Groups collection. To move a group to a specific area or to a new position within the current area, use the PivotGridField.Area and PivotGridField.AreaIndex properties of the first field in the group. Setting these properties for the second and subsequent fields in the group will have no effect.

Grouped fields can be collapsed and expanded by clicking the arrow buttons. Collapsing/expanding a grouped field header hides/shows columns or rows that correspond to grouped child fields. Use the PivotGridField.ExpandedInFieldsGroup property to specify the expansion status of grouped fields in code.

pivotgrid_collapsegroups

#Example: How to Arrange Fields into a Group

This example shows how to arrange fields into a group.

<dxpg:PivotGridControl x:Name="pivotGrid">
    <dxpg:PivotGridControl.Fields>
        <dxpg:PivotGridField x:Name="fieldProduct" FieldName="ProductName" Area="RowArea"
                             Group="{Binding ElementName=fieldGroup1}" GroupIndex="1"/>
        <dxpg:PivotGridField x:Name="fieldCategory" FieldName="CategoryName" Area="RowArea"
                             Group="{Binding ElementName=fieldGroup1}" GroupIndex="0" />
        <dxpg:PivotGridField x:Name="fieldQuarter" FieldName="OrderDate" 
                             Area="ColumnArea" GroupInterval="DateQuarter"/>
        <dxpg:PivotGridField x:Name="fieldUnitPrice" FieldName="UnitPrice"
                             SummaryType="Max" Area="DataArea"/>
    </dxpg:PivotGridControl.Fields>
    <dxpg:PivotGridControl.Groups>
        <dxpg:PivotGridGroup Name="fieldGroup1"/>
    </dxpg:PivotGridControl.Groups>
</dxpg:PivotGridControl>