Open a Report in the Blazor Document Viewer
- 2 minutes to read
This document describes how to open a report in the Blazor Document Viewer (JavaScript-based).
Specify a Report
You can use one of the following options to load a report to the Document Viewer:
- The DxDocumentViewer.ReportName / DxWasmDocumentViewer.ReportName property
Assign a report name to the
ReportNameproperty to open a report:<DxDocumentViewer ReportName="TestReport" Height="1000px" Width="100%" />- The OpenReport method
Specifies a report on the Web Document Viewer’s client side. Allows you to refresh a preview for the loaded report.
<button @onclick="OpenReport">Open Report</button> <DxDocumentViewer @ref="dxDocumentViewer" Height="1000px" Width="100%"> </DxDocumentViewer> @code { DxDocumentViewer dxDocumentViewer; void OpenReport() { dxDocumentViewer.OpenReport("HelloWorld"); } }
For both options, you need to implement and register report name resolution services. For additional information, refer to the following section:
Use Report Name Resolution Services
If you pass a report name to a method that opens a report, you must implement and register one of the following services (to resolve report names).
Note
In Blazor WebAssembly Standalone applications, use async services.
- IReportProvider / IReportProviderAsync
- A recommended service for the Document Viewer and Report Designer. The primary advantage of
IReportProviderservice is that it can be attached to reports created at runtime. IReportProviderAsync uses asynchronous operations. - ReportStorageWebExtension
- This service is called when no other report name resolution services are available. It is designed to obtain reports (stored in our REPX format) from external storage (a file or a database). Note that GetData / GetDataAsync methods return a serialized report. If you use the
GetData/GetDataAsyncmethod to specify the default parameter value for a loaded report, set the Value property to the parameter value.
Open Subreports
The XRSubreport control defines additional reports (subreports) included in the host report. The control’s ReportSource property specifies the report instance used as a subreport, and the ReportSourceUrl property specifies the report name. The ReportSourceUrl property has priority over the ReportSource property.
A subreport is opened automatically alongside the main report. To open a subreport, the Report Viewer passes the XRSubreport.ReportSourceUrl property value to available report name resolution services. Use the IReportProviderAsync service to resolve report names for both the main report and subreports.