Back to Devexpress

DxReportViewer.OpenReportAsync(IReport) Method

xtrareports-devexpress-dot-blazor-dot-reporting-dot-dxreportviewer-dot-openreportasync-x28-devexpress-dot-xtrareports-dot-ireport-x29.md

latest2.7 KB
Original Source

DxReportViewer.OpenReportAsync(IReport) Method

Asynchronously opens the specified report and builds a document for preview.

Namespace : DevExpress.Blazor.Reporting

Assembly : DevExpress.Blazor.Reporting.v25.2.Viewer.dll

NuGet Package : DevExpress.Blazor.Reporting.Viewer

Declaration

csharp
public Task OpenReportAsync(
    IReport report
)
vb
Public Function OpenReportAsync(
    report As IReport
) As Task

Parameters

NameTypeDescription
reportIReport

A report to open. You can specify an XtraReport instance or CachedReportSource instance for large documents.

|

Returns

TypeDescription
Task

An asynchronous operation that loads a report.

|

Remarks

The following code uses a custom helper (MyReportProvider) for report name resolution (to instantiate a report by name). The report instance is passed to the OpenReportAsync method. If a name indicates a large report, the CachedReportSource instance is created and passed to the OpenReportAsync method instead.

razor
@using DevExpress.XtraPrinting.Caching;
@using DevExpress.XtraReports.UI;

<DxReportViewer @ref="reportViewer"></DxReportViewer>

@code { 
    DxReportViewer reportViewer;
    string ReportName;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender) {
          XtraReport report = MyReportProvider.GetReport(ReportName);
          if (Viewer != null) {
              if(ReportName == ReportNames.LargeDatasetName)
                  await Viewer.OpenReportAsync(
                    new CachedReportSource(report, new MemoryDocumentStorage()));
              else
                  await Viewer.OpenReportAsync(report);
          }
        }
    }

}

See Also

DxReportViewer Class

DxReportViewer Members

DevExpress.Blazor.Reporting Namespace