XRPivotGrid.CustomFieldSort Event
Provides the capability to sort data using custom rules.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Event Data
The CustomFieldSort event's data class is DevExpress.XtraReports.UI.PivotGrid.PivotGridCustomFieldSortEventArgs.
Remarks
When sorting by a field, its PivotGridFieldBase.SortMode property defines the pivot grid’s data. Setting this property to PivotSortMode.Custom allows you to implement a custom sorting algorithm for the field by handling the CustomFieldSort event.
When this event is fired, compare two rows using the following parameters.
- The PivotGridCustomFieldSortEventArgsBase`1.Field parameter specifies the field being processed.
- The PivotGridCustomFieldSortEventArgsBase`1.Value1 and PivotGridCustomFieldSortEventArgsBase`1.Value2 parameters identify the values of the rows within this field.
Assign the result of the custom comparison to the PivotGridCustomFieldSortEventArgsBase`1.Result parameter as follows:
When setting Result to -1:
- if data is sorted in ascending order, the first row is positioned above the second row;
- if data is sorted in descending order, the first row is positioned below the second row.
When setting Result to 1:
- if data is sorted in ascending order, the first row is positioned below the second row;
- if data is sorted in descending order, the first row is positioned above the second row.
- To indicate that the rows are equal, set Result to 0. In this case, the rows are arranged according to their indexes in the data source.
After handling the comparison operation, enable the PivotGridCustomFieldSortEventArgsBase`1.Handled parameter. To invoke the default comparison mechanism after the event handler has finished, leave this parameter disabled, in which case the result of a custom comparison is ignored.
Custom sorting and filtering operations are not supported for XRPivotGrid OLAP data sources.