ASPxPivotGrid.Groups Property
Gets the collection of field groups.
Namespace: DevExpress.Web.ASPxPivotGrid
Assembly: DevExpress.Web.ASPxPivotGrid.v19.2.dll
Declaration
Property Value
Type | Description |
---|---|
PivotGridWebGroupCollection | A PivotGridWebGroupCollection object which represents a collection of field groups. |
Remarks
Individual fields can be arranged into a group, which is represented by a PivotGridWebGroup object. Fields contained within a group are treated as a whole, and are always displayed within the same area. These fields cannot be separated by dragging one of them to a different area or hiding it in the customization form. If you drag a field from a group to another position, the entire group is moved.
To ungroup the fields, the group must be removed. Note that fields are not disposed of in this case.
Example
The following example demonstrates how to combine fields into a group at design time. Follow the steps below to create a new group using the ASPxPivotGrid Designer.
- Invoke the ASPxPivotGrid Designer.
In the Fields and Groups page expand the ColumnArea and select the Year, Quarter and Month fields. Hold down the SHIFT or CTRL key while clicking field names to select multiple fields.
Then click the Move to a new group button, that creates a new Year-Quarter-Month group and moves the selected fields into it.
The image below show the result.
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-group-fields-e1876
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);
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Groups property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.