Toolbar - Report Viewer for Blazor
- 2 minutes to read
In This Article
#Commands
Command | Icon | Description | Localization String Id |
---|---|---|---|
First |
![]() |
Navigates to the first page. | Toolbar_First |
Previous |
![]() |
Navigates to the previous page. | Toolbar_Previous |
Go |
![]() |
Navigates to the specified page. | Toolbar_Page |
Next |
![]() |
Navigates to the next page. | Toolbar_Next |
Last |
![]() |
Navigates to the last page. | Toolbar_Last |
Highlight |
![]() |
Highlights all edit fields in the document. | Toolbar_Highlight |
Zoom |
![]() |
Decreases the document zoom factor by 5 percent. | Toolbar_Zoom |
Set |
![]() |
Specifies the document zoom factor. | |
Zoom |
![]() |
Increases the document zoom factor by 5 percent. | Toolbar_Zoom |
![]() |
Prints the document. | Toolbar_Print | |
Export |
![]() |
Exports the document to the format selected in the drop down list. | Toolbar_Export |
Cancel |
![]() |
Interrupts the document creation process and cancels it. | Toolbar_Cancel |
#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.