Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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

public event EventHandler<PivotGridCustomFieldSortEventArgs> CustomFieldSort

#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.

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.

See Also