Skip to main content

Data Filtering in Reports

  • 4 minutes to read

The following data filtering approaches are available in Reports V2.

1. FilterString Property of the XtraReport

The XtraReportBase.FilterString property specifies the filter applied on the client side before a report is displayed.

The ellipsis button displayed next to the FilterString value in the Properties window invokes the FilterString Editor dialog, which simplifies filter creation.


2. Criteria Property of the Data Source

The data source‘s DataSourceBase.Criteria property is used to set a filter on the server side.

The ellipsis button displayed next to the Criteria value in the Properties window invokes the FilterString Editor dialog, which simplifies criteria creation.


You can also use the following code to modify criteria 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.ISupportCriteria)report.DataSource;
    dataSource.Criteria = DevExpress.Data.Filtering.CriteriaOperator.Parse(
        "StartsWith(LastName, 'A')");

3. XtraReport Parameters

You can use Report Parameters in Filter Criteria. To refer to a parameter value, precede the parameter value with a question mark (e.g., “[Name] = ?parameterName”). For additional information on parameter use in the Filter Builder, refer to the following article: Data Filtering Overview.

4. Parameters Object

You can use a custom non-persistent class inherited from the ReportParametersObjectBase abstract class included in the Reports V2 module, instead of XtraReports parameters. This object’s Detail View will be displayed in a popup dialog before a report is displayed. Filtering and sorting specified via this object’s ReportParametersObjectBase.GetCriteria and ReportParametersObjectBase.GetSorting methods are applied to the data source. This approach is useful for defining complex filtering and sorting.

To add your Parameters Object to the Application Model and to adjust the object’s Detail View layout in the Model Editor, apply the DomainComponentAttribute to the class’ declaration.

using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp.ReportsV2;
// ...
public class DemoParameters : ReportParametersObjectBase {
    public bool SortByFirstName { get; set; }
    public bool FilterByFirstName { get; set; }
    public string FirstName { get; set; }
    public bool FilterByPosition { get; set; }
    public Position ContactPosition { get; set; }

    public DemoParameters(IObjectSpaceCreator provider) : base(provider) {
        ContactPosition = ObjectSpace.FirstOrDefault<Position>(position => position.Title == "Developer");

    protected override IObjectSpace CreateObjectSpace() {
        return objectSpaceCreator.CreateObjectSpace(typeof(Contact));

    public override CriteriaOperator GetCriteria() {
        CriteriaOperator criteriaName = null;
        CriteriaOperator criteriaPosition = null;
        if (FilterByFirstName) {
            criteriaName = CriteriaOperator.Parse("FirstName = ?", FirstName);
        if (FilterByPosition) {
            criteriaPosition = CriteriaOperator.Parse("Position.Oid = ?", ContactPosition.Oid);
        return CriteriaOperator.And(criteriaName, criteriaPosition);

    public override SortProperty[] GetSorting() {
        List<SortProperty> sorting = new List<SortProperty>();
        if (SortByFirstName) {
            sorting.Add(new SortProperty(nameof(FirstName), SortingDirection.Ascending));
        return sorting.ToArray();

Associate the Report Parameters Object with the Report

  • If a report is created at runtime, you can associate the Report Parameters Object via the IReportDataV2.ParametersObjectType property. Right-click the report in the Reports list view and choose Edit. Then, choose the Parameters Object Type in the invoked Detail View.


  • If a report is predefined (created at design time), the Parameters object type can be passed to the PredefinedReportsUpdater.AddPredefinedReport method.

        "Contacts by Department", typeof(ContactsReport), typeof(MyParametersObject));

    For details on adding predefined reports, refer to the PredefinedReportsUpdater class description.