Skip to main content
A newer version of this page is available. .
All docs
V20.2
.NET Framework 4.5.2+

How to: Access the Report Preview Control (Blazor)

This example demonstrates how to access the adapter of the DxDocumentViewer component that Blazor XAF applications use to display reports.

When a user previews a report, a Blazor application opens a Detail View that contains ReportViewerViewItem. Follow the steps below to access this View Item and its component:

  1. Add the DevExpress.ExpressApp.ReportsV2.Blazor NuGet package to the Blazor Module project (MySolution.Module.Blazor).
  2. In the Blazor Module project (MySolution.Module.Blazor), create a View Controller.
  3. Set its View property to DetailView and TargetViewId to the View’s identifier. The ReportsBlazorModuleV2.ReportViewerDetailViewName constant stores this identifier.
  4. In the overridden OnActivated method, call the CustomizeViewItemControl<T>(DetailView, Controller, Action<T>) method.
  5. Use the ViewItem.Control property to access the Report Viewer’s control.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2.Blazor;
// ...
public class AccessReportViewerController : ViewController<DetailView> {
    public AccessReportViewerController() {
        TargetViewId = ReportsBlazorModuleV2.ReportViewerDetailViewName;
    }
    protected override void OnActivated() {
        base.OnActivated();
        View.CustomizeViewItemControl<ReportViewerViewItem>(this, CustomizeReportViewerViewItem);
    }
    private void CustomizeReportViewerViewItem(ReportViewerViewItem reportViewerViewItem) {
        string reportName = ((ReportViewerViewItem.DxDocumentViewerAdapter)reportViewerViewItem.Control).ComponentModel.ReportName;
        // ...
    }
}