Demo for passing parametrs to blazor native

1 Answer 78 Views
DataSources Report Viewer - Blazor
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Sami asked on 01 Jul 2023, 01:49 AM

I want to pass parameters tho the report using  Blazor native viewer. I found some samples with HTML viewer but the code doesn't work for the native viewer. Do you have a sample of how to implement it?

I try implementing a custom resolver but until now it is not working.

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 05 Jul 2023, 08:52 AM

Hi Sami,

When it comes to updating the values of the report parameter of the native Blazor Report Viewer from code, in order to do so, you need to re-assign a whole new ReportSourceOptions object to the property bound to the Report Viewer's ReportSource, for example:

<button onclick="@RefreshViewer">Refresh with new parameter value</button>

<ReportViewer ServiceUrl="/api/reports"
    @ref=rv1
    @bind-ReportSource="@ReportSource"
    @bind-ScaleMode="@ScaleMode"
    @bind-ViewMode="@ViewMode"
    @bind-ParametersAreaVisible="@ParametersAreaVisible"
    @bind-DocumentMapVisible="@DocumentMapVisible"
    @bind-Scale="@Scale"
    PageMode="@PageMode.ContinuousScroll"
    EnableSendEmail="true"
    ServiceType="@ReportViewerServiceType.REST"
    Height="800px"
    Width="100%">
</ReportViewer>
@code {
    ...
    public ReportSourceOptions ReportSource { get; set; } = new ReportSourceOptions(
        "Report1.trdp", 
        new Dictionary<string, object>
    {});

    void RefreshViewer()
    {
        ReportSource = new ReportSourceOptions() {  Report = ReportSource.Report, Parameters = new Dictionary<string, object>() { { "parameter", "value" } } };
    }

Hope this helps!

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
DataSources Report Viewer - Blazor
Asked by
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or