Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Toolbar - Report Viewer for Blazor

  • 2 minutes to read
In This Article

Blazor Report Viewer Toolbar

#Commands

Command Icon Description Localization String Id
FirstPage Blazor Viewer Toolbar First Page Navigates to the first page. Toolbar_FirstPage
PreviousPage Blazor Viewer Toolbar Previous Page Navigates to the previous page. Toolbar_PreviousPage
GoToPage Blazor Viewer Toolbar Go to Page Navigates to the specified page. Toolbar_PageOfPagesFormat
NextPage Blazor Viewer Toolbar Next Page Navigates to the next page. Toolbar_NextPage
LastPage Blazor Viewer Toolbar Last Page Navigates to the last page. Toolbar_LastPage
HighlightEditingFields Blazor Viewer Toolbar Highlight Editing Fields Highlights all edit fields in the document. Toolbar_HighlightEditingFields
ZoomOut Blazor Viewer Toolbar Zoom Out Decreases the document zoom factor by 5 percent. Toolbar_ZoomOut
SetZoomFactor Blazor Viewer Toolbar Zoom Out Specifies the document zoom factor.
ZoomIn Blazor Viewer Toolbar Zoom In Increases the document zoom factor by 5 percent. Toolbar_ZoomIn
Print Blazor Viewer Toolbar Print Prints the document. Toolbar_Print
ExportTo Blazor Viewer Toolbar ExportTo Exports the document to the format selected in the drop down list. Toolbar_ExportTo
CancelDocumentCreation Blazor Viewer Toolbar Cancel Document Creation Interrupts the document creation process and cancels it. Toolbar_CancelDocumentCreation

#Customization

Handle the OnCustomizeToolbar event or use the ToolbarModel property to modify the Report Viewer toolbar. The following code snippet hides the ExportTo button:

C#
@using DevExpress.Blazor.Reporting
@using DevExpress.XtraReports.UI

@*...*@

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

@code{
    DxReportViewer reportViewer { get; set; }
    XtraReport Report { get; set; }
    // ...
    protected override void OnAfterRender(bool firstRender)
    {
        reportViewer.ToolbarModel.AllItems
            .Find(item=>item.Id=="ExportTo").Visible = false;
        base.OnAfterRender(firstRender);
    }
}

The following code removes all export formats from the Export To drop-down list except PDF and Image formats:

C#
@using DevExpress.Blazor.Reporting
@using DevExpress.Blazor.Reporting.Models
@using DevExpress.XtraReports.UI
@* ... *@

@code {
    XtraReport Report;

    protected override void OnAfterRender(bool firstRender) {
        ToolbarModel toolbarModel = reportViewer.ToolbarModel;
        var exportItem = toolbarModel.AllItems.Single(item =>
            item.Id == ToolbarItemId.ExportTo);
        exportItem.Items = exportItem.Items.Where(el =>
        {
            var format = ((ExportFormatItem)el).Format;
            return format == DevExpress.XtraPrinting.ExportFormat.Pdf ||
                format == DevExpress.XtraPrinting.ExportFormat.Image;
        }).ToList();
        base.OnAfterRender(firstRender);
    }
}

The image below shows the customized toolbar.

Blazor Report Viewer Custom Toolbar Export Formats