Skip to main content
A newer version of this page is available. .

Data Sorting in Reports V2

The following data sorting approaches are available in Reports V2.

  1. Use XtraReports sorting.
  2. Use the CollectionSourceBase.Sorting property of the CollectionDataSource or ViewDataSource (see Data Sources for Reports V2).
  3. Use ReportParametersObjectBase.GetSorting method of the Parameters Object (a ReportParametersObjectBase descendant).

Sorting Property of the Data Source

The CollectionSourceBase.Sorting property of the CollectionDataSource and ViewDataSource components specifies a list of sorting rules. You can add rules by clicking the ellipsis button next to the Sorting value in the Properties window.

ReportsV2_Sorting

The data is sorted on the client side.

You can also use the following code to modify Sorting from Report Scripts.

private void xtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
    var report = (DevExpress.XtraReports.UI.XtraReport)sender;
    var dataSource = (DevExpress.Persistent.Base.ReportsV2.ISupportSorting)report.DataSource;
    dataSource.Sorting.Clear();
    dataSource.Sorting.Add(
        new DevExpress.Xpo.SortProperty("FullName", DevExpress.Xpo.DB.SortingDirection.Ascending));
}

Parameters Object

Sorting via the Parameters Object is performed in a manner similar to filtering. For details, refer to the Data Filtering in Reports V2 topic.