PivotGridFieldBase.GroupInterval Property

Gets or sets how the values of the current column or row field are combined into groups.

Namespace: DevExpress.XtraPivotGrid

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

Declaration

[DefaultValue(PivotGroupInterval.Default)]
[PropertyCategory(PropertyCategory.LegacyBinding)]
[PropertyCategory(PropertyCategory.RelationalSource)]
public PivotGroupInterval GroupInterval { get; set; }
<PropertyCategory(PropertyCategory.RelationalSource)>
<PropertyCategory(PropertyCategory.LegacyBinding)>
<DefaultValue(PivotGroupInterval.Default)>
Public Property GroupInterval As PivotGroupInterval

Property Value

Type Default Description
PivotGroupInterval

Default

A PivotGroupInterval value that specifies how the values of the current field are combined into groups.

Remarks

Values of column and row fields can be combined into groups. By default, the control doesn't group the values of these fields and displays all their unique values along its left and top edge. The GroupInterval property allows you to change the logic used to decide which values should be grouped together.

For instance, for a field which displays date/time values, you can set its GroupInterval property to PivotGroupInterval.DateYear. As a result, the field's values will be grouped within a few categories, each of which will combine different values that belong to the same year.

See the PivotGroupInterval topic, for details on the available group modes.

If group modes available via the GroupInterval property doesn't suit your needs, you can implement custom grouping intervals via the PivotGridControl.CustomGroupInterval event.

Examples

Assume that the PivotGridControl is bound to a data table that contains an OrderDate field. In the following example two PivotGridField fields are created and displayed in the Column Header Area. Each is bound to the OrderDate field. The first Pivot Grid Control field's values will be grouped by years, the second field's values will be grouped by months. To group data, the PivotGridFieldBase.GroupInterval property is used.

The result of the code is shown below:

PivotGridField_GroupInterval_ex

using DevExpress.XtraPivotGrid;

// Create column fields and bind them to the 'OrderDate' datasource field.
PivotGridField fieldYear = new PivotGridField("OrderDate", PivotArea.ColumnArea); 
PivotGridField fieldMonth = new PivotGridField("OrderDate", PivotArea.ColumnArea);
// Add the fields to the field collection.
pivotGridControl1.Fields.Add(fieldYear);
pivotGridControl1.Fields.Add(fieldMonth);
// Set the caption and group mode of the fields.
fieldYear.GroupInterval = PivotGroupInterval.DateYear;
fieldYear.Caption = "Year";
fieldMonth.GroupInterval = PivotGroupInterval.DateMonth;
fieldMonth.Caption = "Month";
See Also