How to display report book in telerik report viewer for Telerik UI for Blazor

1 Answer 48 Views
General Discussions Report Book Report Viewer - Blazor
Jackson
Top achievements
Rank 1
Iron
Iron
Jackson asked on 15 Oct 2024, 08:20 AM

hi,

    I want to display a report book with the .trbp suffix in the ReportViewer component of Telerik UI For Blazor, but when I assign the ReportSource, it prompts that it cannot be converted from Telerik.Reporting.UriReportSource to Telerik.ReportViewer.Blazor.ReportSourceOptions. Is there any specific case reference?

 

ReportViewer.razor code::
<ReportViewer ViewerId="rv1"
              ServiceUrl="API/Reports"
              ReportSource="@BookReportSource"
              Parameters="@(new ParametersOptions { Editors = new EditorsOptions { MultiSelect = EditorType.ComboBox, SingleSelect = EditorType.ComboBox } })"
              ScaleMode="@ScaleMode"
              ViewMode="@ViewMode"
              PageMode="PageMode.SinglePage" />

public object BookReportSource { get; set; } = new Telerik.Reporting.UriReportSource()
{
    Uri = $"{ReportParameters.ReportName}.trbp"
};

protected override Task OnParametersSetAsync()
{
    switch (ReportParameters.ReportName)
    {
        case nameof(Report.StaffCapitalisationRatioReport):
            BookReportSource.Parameters.Add("StartDate", ReportParameters.StartDate);
            BookReportSource.Parameters.Add("EndDate", ReportParameters.EndDate);
            BookReportSource.Parameters.Add("BusinessUnit", ReportParameters.BusinessUnit);
            BookReportSource.Parameters.Add("FormatDate", Convert.ToDateTime(ReportParameters.EndDate).ToString("yyyy / MMMM"));
            BookReportSource.Parameters.Add("StaffNo", ReportParameters.StaffNo);
            BookReportSource.Parameters.Add("NormalWeekdayHours", ReportParameters.NormalWeekdayHours);
            BookReportSource.Parameters.Add("NormalWeekendHours", ReportParameters.NormalWeekendHours);
            break;
    }

    return base.OnParametersSetAsync();
}



1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 17 Oct 2024, 01:42 PM

Hello Jackson,

Thank you for the shared code!

The Blazor Report Viewer requires an object of type Telerik.ReportViewer.Blazor.ReportSourceOptions, for example:

<ReportViewer @ref="reportViewer1"
              ViewerId="rv1"
              ServiceUrl="/api/reports"
              ReportSource="@(new ReportSourceOptions
                              {
                                  Report = "Report Catalog.trbp",
                              })" />

The Telerik.Reporting.ReportSource class and its inheritors are used on the server, internally, but the report viewer expects a Telerik.ReportViewer.Blazor.ReportSourceOptions object.

Please try using the suggested type and let me know how it goes.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
General Discussions Report Book Report Viewer - Blazor
Asked by
Jackson
Top achievements
Rank 1
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or