Skip to main content
All docs
V24.1
.NET Framework 4.5.2+

IReportDataSourceHelper.CustomSetupReportDataSource Event

Occurs when the report data source is initialized.

Namespace: DevExpress.ExpressApp.ReportsV2

Assembly: DevExpress.ExpressApp.ReportsV2.v24.1.dll

Declaration

event EventHandler<CustomSetupReportDataSourceEventArgs> CustomSetupReportDataSource

Event Data

The CustomSetupReportDataSource event's data class is DevExpress.ExpressApp.ReportsV2.CustomSetupReportDataSourceEventArgs.

Remarks

Handle this event to apply criteria and sorting manually. In the handler, you can use the IReportDataSourceHelper.GetMasterReportDataSource method to access the data source.

You can also use this event to use a custom Data Source component (inherited from DataSourceBase).

The code snippets below demonstrate how to subscribe to this event:

In Application Builder Code

In the application’s Startup.cs file, add the OnCustomSetupReportDataSource event handler to the builder.Modules.AddReports method call as shown below:

File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs

using DevExpress.ExpressApp.ApplicationBuilder;
// ...
builder.Modules
    .AddReports(options => {
        // ...
        options.Events.OnCustomSetupReportDataSource = context => {
            context.Report.DataSource = new CustomDataSource();
        };
    })
// ...

Through Dependency Injection

Note

The technique shown in this section is not supported for Web API Service.

Use Dependency Injection to access the IReportDataSourceHelper service and add a handler to its CustomSetupReportDataSource event.

using DevExpress.ExpressApp.ReportsV2;
using Microsoft.Extensions.DependencyInjection;
// ...
// Use Dependency Injection to access the IServiceProvider.
var helper = serviceProvider.GetRequiredService<IReportDataSourceHelper>();
helper.CustomSetupReportDataSource += delegate (object sender, CustomSetupReportDataSourceEventArgs e) {
    e.Report.DataSource = new CustomDataSource();
};
See Also