You can hide the component toolbar to show customized user interface or to customize the toolbar icons and element’s appearances using the templates and Report Viewer toolbar customization properties.
In this tutorial, the
sales-order-detail.rdl
report is used and it can be downloaded from here. You can add the reports from the Syncfusion installation location. For more information, refer to Samples and demos.
To hide toolbar items, set the ToolbarSettings
property. The following code can be used to remove the parameter option from the toolbar and hide the parameter block.
Similarly, you can show or hide all other toolbar options with the help of toolbarSettings.items
enum.
The following code example demonstrates how to hide the parameter block in the Report Viewer at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to hide the parameter block in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ToolbarSettings = new BoldReports.Models.ReportViewer.ToolbarSettings();
this.viewer.ToolbarSettings.Items = BoldReports.ReportViewerEnums.ToolbarItems.All & ~BoldReports.ReportViewerEnums.ToolbarItems.Parameters;
}
To enable stop option in toolbar, set the ToolbarSettings.Items
property to BoldReports.ReportViewerEnums.ToolbarItems.All
. The following code can be used to enable stop option in toolbar.
The following code example demonstrates how to enable stop option in the Report Viewer toolbar at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to enable stop option in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ToolbarSettings = new BoldReports.Models.ReportViewer.ToolbarSettings();
this.viewer.ToolbarSettings.Items = BoldReports.ReportViewerEnums.ToolbarItems.All;
}
To enable export setup option in toolbar, set the ToolbarSettings.Items
property to BoldReports.ReportViewerEnums.ToolbarItems.All
. The following code can be used to enable export setup option in toolbar.
The following code example demonstrates how to enable export setup option in the Report Viewer toolbar at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to enable export setup option in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ToolbarSettings = new BoldReports.Models.ReportViewer.ToolbarSettings();
this.viewer.ToolbarSettings.Items = BoldReports.ReportViewerEnums.ToolbarItems.All;
}
To enable search text option in toolbar, set the ToolbarSettings.Items
property to BoldReports.ReportViewerEnums.ToolbarItems.All
. The following code can be used to enable search text option in toolbar.
The following code example demonstrates how to enable search text option in the Report Viewer toolbar at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to enable search text option in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ToolbarSettings = new BoldReports.Models.ReportViewer.ToolbarSettings();
this.viewer.ToolbarSettings.Items = BoldReports.ReportViewerEnums.ToolbarItems.All;
}
To hide the Report Viewer toolbar, set the ShowToolbar
property to false.
The following code example demonstrates how to hide the toolbar in the Report Viewer at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to hide the toolbar in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ToolbarSettings = new BoldReports.Models.ReportViewer.ToolbarSettings();
this.viewer.ToolbarSettings.ShowToolbar = false;
}
The Report Viewer provides the ExportOptions
property to show or hide the default export types available in the component. The following code hides the HTML export type from the default export options.
The following code example demonstrates how to decide or hide the export option in the Report Viewer at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl">
</Bold:ReportViewer>
</div>
The following code example demonstrates how to decide or hide the export option in your application’s Page_Load()
function.
protected void Page_Load(object sender, EventArgs e)
{
this.viewer.ExportSettings = new BoldReports.Models.ReportViewer.ExportSettings();
this.viewer.ExportSettings.ExportOptions = BoldReports.ReportViewerEnums.ExportOptions.All & ~BoldReports.ReportViewerEnums.ExportOptions.Html;
}
To add custom items to the export drop-down available in the Report Viewer toolbar, use the property CustomItems
and provide the JSON array of collection input with the Index
, CssClass
name, and Value
properties. Register the OnClientExportItemClick
event to handle the custom item actions as given in following code snippet.
You can use the following codes to add custom items to the export drop-down in your application’s Page_Load()
function using ExportSettings
property.
protected void Page_Load(object sender, EventArgs e)
{
ExportSettings exportSettings = new ExportSettings();
exportSettings.CustomItems = new List<CustomExportItem>();
var exportItem1 = new CustomExportItem() { Index = 2, CssClass = "", Value = "Text File" };
var exportItem2 = new CustomExportItem() { Index = 4, CssClass = "", Value = "DOT" };
exportSettings.CustomItems.Add(exportItem1);
exportSettings.CustomItems.Add(exportItem2);
this.viewer.ExportSettings = exportSettings;
}
You can use the following codes to create an OnClientExportItemClick
event at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl" OnClientExportItemClick="onExportItemClick">
</Bold:ReportViewer>
</div>
<script type="text/javascript">
//Export click event handler
function onExportItemClick(args) {
if (args.value === "Text File") {
//Implement the code to export report as Text
alert("Text File export option clicked");
} else if (args.value === "DOT") {
//Implement the code to export report as DOT
alert("DOT export option clicked");
}
}
</script>
You can add custom items to Report Viewer toolbar using the ToolbarSettings
property. You must register the OnClientToolBarItemClick
event to handle the newly added custom items action.
You can use the following codes to add new toolbar group in your application’s Page_Load()
function using ToolbarSettings
property.
protected void Page_Load(object sender, EventArgs e)
{
ToolbarSettings toolbarSettings = new ToolbarSettings();
toolbarSettings.CustomItems = new List<CustomItem>();
var customItem = new CustomItem()
{
GroupIndex = 1,
Index = 1,
CssClass = "e-icon e-mail e-reportviewer-icon",
Type = BoldReports.ReportViewerEnums.ToolBarItemType.Default,
Id = "E-Mail",
Tooltip = new ToolTip() { Header = "E-Mail", Content = "Send rendered report as mail attachment" }
};
toolbarSettings.CustomItems.Add(customItem);
this.viewer.ToolbarSettings = toolbarSettings;
}
You can use the following codes to create an OnClientToolBarItemClick
event at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl" OnClientToolBarItemClick="onToolBarItemClick">
</Bold:ReportViewer>
</div>
<script type="text/javascript">
function onToolBarItemClick(args) {
if (args.value == "E-Mail") {
alert('Action Triggered');
}
}
</script>
To add a custom item to existing toolbar group use the property CustomGroup
in ToolbarSettings
and provide the JSON array of collection input with the GroupIndex
, Items
, Type
, CssClass
name, and Tooltip
properties as given in following code snippet.
You can use the following codes to add custom item to exiting toolbar group in your application’s Page_Load()
function using ToolbarSettings
property.
protected void Page_Load(object sender, EventArgs e)
{
ToolbarSettings toolbarSettings = new ToolbarSettings();
var groupItem = new List<CustomItem>();
groupItem.Add(new CustomItem()
{
CssClass = "e-icon e-mail e-reportviewer-icon CustomGroup",
Type = BoldReports.ReportViewerEnums.ToolBarItemType.Default,
Id = "CustomGroup",
Tooltip = new ToolTip() { Header = "CustomGroup", Content = "toolbargroups" }
});
groupItem.Add(new CustomItem()
{
CssClass = "e-icon e-mail e-reportviewer-icon subCustomGroup",
Type = BoldReports.ReportViewerEnums.ToolBarItemType.Default,
Id = "subCustomGroup",
Tooltip = new ToolTip() { Header = "subCustomGroup", Content = "subtoolbargroups" }
});
toolbarSettings.CustomGroups.Add(new CustomGroup() { Items = groupItem, GroupIndex = 4 });
this.viewer.ToolbarSettings = toolbarSettings;
}
You can use the following codes to create an OnClientToolBarItemClick
event at client side.
<div style="height: 650px;width: 950px;min-height:404px;">
<Bold:ReportViewer runat="server" ID="viewer"
ReportServiceUrl="/api/ReportViewer"
ReportPath="~/Resources/sales-order-detail.rdl" OnClientToolBarItemClick="onToolBarItemClick">
</Bold:ReportViewer>
</div>
<script type="text/javascript">
function onToolBarItemClick(args) {
if (args.value === "CustomGroup") {
//Implement the code to CustomGroup toolbar option
alert("CustomGroup toolbar option clicked");
}
if (args.value === "subCustomGroup") {
//Implement the code to subCustomGroup toolbar option
alert("SubCustomGroup toolbar option clicked");
}
}
</script>
To add new toolbar group and custom items to it, use the property CustomItems
in ToolbarSettings
and provide the JSON array of collection input with the GroupIndex
, Index
properties. The CustomItems
must have the properties Type
, CssClass
and Tooltip
as given in following code snippet.
You can use the following codes to add new toolbar group in your application’s Page_Load()
function using ToolbarSettings
property.
protected void Page_Load(object sender, EventArgs e)
{
ToolbarSettings toolbarSettings = new ToolbarSettings();
toolbarSettings.CustomItems = new List<CustomItem>();
var customItem = new CustomItem()
{
GroupIndex = 1,
Index = 1,
CssClass = "e-icon e-mail e-reportviewer-icon",
Type = BoldReports.ReportViewerEnums.ToolBarItemType.Default,
Id = "E-Mail",
Tooltip = new ToolTip() { Header = "E-Mail", Content = "Send rendered report as mail attachment" }
};
toolbarSettings.CustomItems.Add(customItem);
this.viewer.ToolbarSettings = toolbarSettings;
}