Skip to main content
All docs
V24.2
.NET 8.0+

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

How to: Access the Report Preview Control (ASP.NET Core Blazor)

This example accesses the DxDocumentViewer component that ASP.NET Core Blazor XAF applications use to display reports.

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

  1. Add the Reports V2 Module to your application. For more information, refer to the following topic: Add Reports V2 Module to an Existing XAF Application.
  2. Create a Detail View Controller and specify the TargetViewId as ReportsBlazorModuleV2.ReportViewerDetailViewName.
  3. Override the OnActivated method and access the Report Viewer’s control as demonstrated in the following code snippet:

    C#
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.ReportsV2.Blazor;
    using DevExpress.XtraReports;
    
    namespace YourSolutionName.Blazor.Server.Controllers;
    
    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) {
            //Access the Report Viewer's control.
            IReport report = reportViewerViewItem.ReportViewerModel.Report;
            // ...
        }
    }