New to Telerik Reporting? Download free 30-day trial

Overview

The Native Blazor Report Viewer exposes commands that allow to control its behavior from application code.

Executing A Command

To execute a command, it is required to first get a reference to the report viewer object using the @ref attribute. Then, the referenced property/field can be used to invoke the ExecuteCommand method. The ExecuteCommand method has the following signature:

void ExecuteCommand(string commandName, string commandValue(optional))

All commands, except for the Export command, require a single argument for this method, which is the commandName. The commandValue is used only by the Export command to specify the exporting format.

For example, the Refresh and Export commands of the current report can be triggered like this:

<button type="button" class="btn btn-light btn-sm" @onclick="RefreshReport">Refresh Report</button>
<button type="button" class="btn btn-light btn-sm" @onclick="Export">Export Report to PDF</button>
...
<ReportViewer
    ServiceUrl="/api/reports"
    @ref="@ViewerInstance"
</ReportViewer>
...
@code {
    public ReportViewer ViewerInstance { get; set; } 

    void RefreshReport()
    {
         ViewerInstance.ExecuteCommand("Refresh");
    }
    void Export()
    {
        ViewerInstance.ExecuteCommand("Export", "PDF");
    }
}

Commands List

Command Name Arguments Description
NavigateBackward None Goes back to the previously rendered report from history.
NavigateForward None Goes forward to the previously rendered report from history.
StopRendering None Stop the rendering of the current report at the first possible moment.
Refresh None Refreshes the report viewer.
Print None Triggers the report viewer printing operation.
SendMail None Triggers the Email sending functionality if implemented.
Search None Shows or hides the search dialog.
Export The rendering extension name, e.g. "PDF" Exports the report, using the respective rendering extension name.
FirstPage None Goes to the first page of the report.
LastPage None Goes to the last page of the report
NextPage None Goes to the next page of the report.
PreviousPage None Goes to the previous page of the report.
ZoomIn None Zoom-in the report.
ZoomOut None Zoom-out the report.
TogglePrintPreview None Toggles between Print Preview and Interactive view modes - Interactive vs Print Layout
ToggleScaleMode None Changes the scale mode of the report.
ToggleDocumentMap None Shows or hides the document map.
ToggleParametersArea None Shows or hides the parameters area.

See Also

In this article