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

How to: Group Fields

  • 3 minutes to read

Follow the steps below to create a new group at design time:

  • Invoke the ASPxPivotGrid Designer.
  • In the Fields and Groups page expand the ColumnArea and select the Year, Quarter and Month fields. Hold down SHIFT or CTRL while you click field names to select multiple fields.

    ex_SelectFields

  • Then click the Move to a new group button, that creates a new Year-Quarter-Month group and moves the selected fields into it.

    ex_GreateFieldGroup

The image below show the result.

ex_GreatedFieldGroup

The following code demonstrates how to combine fields into a group at runtime.

In this example, three fields (Year, Quarter and Month, respectively) are combined into a new group. This ensures that the Year field will be followed by Quarter which in its turn is followed by Month. If the Year field is being dragged to another area other fields will be dragged as well.

View Example

using System;
using DevExpress.Web.ASPxPivotGrid;

namespace ASPxPivotGridFieldGroups
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Creates a PivotGridWebGroup instance.
            PivotGridWebGroup groupOrderDate = new PivotGridWebGroup();

            // Adds fields to the created group.
            groupOrderDate.Fields.Add(fieldOrderYear);
            groupOrderDate.Fields.Add(fieldOrderQuarter);
            groupOrderDate.Fields.Add(fieldOrderMonth);

            // Adds the created group to the collection of the ASPxPivotGrid groups.
            ASPxPivotGrid1.Groups.Add(groupOrderDate);
        }
    }
}