ASPxPivotGrid.CustomGroupInterval Event
Enables grouping axis values, using your own criteria.
Namespace: DevExpress.Web.ASPxPivotGrid
Assembly: DevExpress.Web.ASPxPivotGrid.v22.2.dll
NuGet Package: DevExpress.Web
Declaration
Event Data
The CustomGroupInterval event's data class is PivotCustomGroupIntervalEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Field | Gets the field being processed. Inherited from PivotFieldEventArgsBase<T>. |
GroupValue | Gets or sets a group value. |
Value | Gets the processed field value. |
Remarks
Note
This member is not supported in Optimized, OLAP, and Server modes. Use ExpressionDataBinding for Optimized mode instead.
The CustomGroupInterval event is raised for each row or column field whose PivotGridFieldBase.GroupInterval property is set to ‘Custom’.
Objects assigned to the GroupInterval property must be of the same type for all values of a particular field.
Example
This example shows how to provide a custom criteria used to group axis values. The Custom Group Intervals feature is used to group product names and make the report more readable. The Product axis will show three intervals (“A-J”, “K-S” and “T-Z”).
The ‘Products’ field’s PivotGridFieldBase.GroupInterval property is set to Custom at design-time. The grouping logic is implemented within the ASPxPivotGrid.CustomGroupInterval
event handler.
The image below shows the result:
protected void ASPxPivotGrid1_CustomGroupInterval(object sender,
DevExpress.Web.ASPxPivotGrid.PivotCustomGroupIntervalEventArgs e)
{
if (e.Field.Caption != "Products") return;
if (Convert.ToChar(e.Value.ToString()[0]) < 'K') {
e.GroupValue = "A-J";
return;
}
if (Convert.ToChar(e.Value.ToString()[0]) > 'J' && Convert.ToChar(e.Value.ToString()[0]) < 'T') {
e.GroupValue = "K-S";
return;
}
if (Convert.ToChar(e.Value.ToString()[0]) > 'S')
e.GroupValue = "T-Z";
}