Search results
PDF

Toolbar customization

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 Bold Reports installation location. For more information, refer to Samples and demos.

Hide toolbar items

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. Use the following code snippet in App.js file.

Similarly, you can show or hide all other toolbar options with the help of toolbarSettings.items enum.

Use the following code snippet in App.js file.

var toolbarSettings = {
  items: ~ej.ReportViewer.ToolbarItems.Parameters
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

The following code sample hides the print options from the toolbar items which can be used in the App.js file.

var toolbarSettings = {
  items: ~ej.ReportViewer.ToolbarItems.Print
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Enable stop option in toolbar

To enable stop option in toolbar, set the toolbarSettings.items property to ej.ReportViewer.ToolbarItems.All. The following code can be used to enable stop option in toolbar in App.js file.

var toolbarSettings = {
  items: ej.ReportViewer.ToolbarItems.All
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Enable export setup option in toolbar

To enable export setup option in toolbar, set the toolbarSettings.items property to ej.ReportViewer.ToolbarItems.All. The following code can be used to enable export setup option in toolbar in App.js file.

var toolbarSettings = {
  items: ej.ReportViewer.ToolbarItems.All
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Enable search text option in toolbar

To enable search text option in toolbar, set the toolbarSettings.items property to ej.ReportViewer.ToolbarItems.All. The following code can be used to enable search text option in toolbar in App.js file.

var toolbarSettings = {
  items: ej.ReportViewer.ToolbarItems.All
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Hide toolbar

To hide the Report Viewer toolbar, set the showToolbar property to false.

var toolbarSettings = {
  showToolbar: false
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Decide or hide the export option

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 which is used in App.js file.

var exportsettings = {
    exportOptions: ej.ReportViewer.ExportOptions.All & ~ej.ReportViewer.ExportOptions.HTML
    };

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            exportSettings = {exportsettings}>
            </BoldReportViewerComponent>
    </div>
  );
}

Add custom items to the export drop-down

To add custom items to the export drop-down available in the Report Viewer toolbar, use the customItems property and provide the JSON array of collection input with the index, cssClass name, and value properties. Register the exportItemClick event to handle the custom item actions as given in following code snippet, which can be used in App.js file.

var exportsettings = {
    customItems: [{
        index: 2,
        cssClass: '',
        value: 'Text File'
        },
        {
        index: 4,
        cssClass: '',
        value: 'DOT'
        }]
    };

//Export click event handler
function onExportItemClick(event) {
    if (event.value === "Text File") {
        //Implement the code to export report as Text
        alert("Text File export option clicked");
    } else if (event.value === "DOT") {
        //Implement the code to export report as DOT
        alert("DOT export option clicked");
        }
    }

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            exportSettings = {exportsettings}
            exportItemClick = {onExportItemClick}>
            </BoldReportViewerComponent>
    </div>
  );
}

Add custom toolbar item

You can add custom items to Report Viewer toolbar using the toolbarSettings property. You should register the toolBarItemClick event to handle the newly added custom items action.

Add custom item to exiting toolbar group

To add a custom item to existing toolbar group use the customItems property in toolbarSettings and provide the JSON array of collection input with the groupIndex, index, itemType, cssClass name, and tooltip properties as given in following code snippet, which is used in App.js file.

var toolbarSettings = {
  showToolbar: true,
  items: ~ej.ReportViewer.ToolbarItems.Print,
  customItems: [{
    groupIndex: 1,
    index: 1,
    type: 'Default',
    cssClass: "e-icon e-mail e-reportviewer-icon",
    id: 'E-Mail',
    tooltip: {
        header: 'E-Mail',
        content: 'Send rendered report as mail attachment'
        }
    }]
}

 //Toolbar click event handler
 function onToolBarItemClick(event) {
  if (event.value === "CustomItem") {
      //Implement the code to CustomItem toolbar option
      alert("Email item toolbar option Clicked");
  }
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}
            toolBarItemClick = {onToolBarItemClick}>
            </BoldReportViewerComponent>
    </div>
  );
}

Add new toolbar group

To add a new toolbar group and custom items to it, use the customGroups property in the toolbarSettings and provide the JSON array of collection input with the groupIndex and items properties. The items should have the itemType, cssClass, and tooltip properties as given in following code snippet, which is used in the App.js file.

var toolbarSettings = {
  showToolbar: true,
    items: ~ej.ReportViewer.ToolbarItems.Print,
    customGroups: [{
        items: [{
            type: 'Default',
            cssClass: "e-icon e-mail e-reportviewer-icon CustomGroup",
            id: 'CustomGroup',
            tooltip: { header: 'CustomGroup', content: 'toolbargroups' }
            },
            {
            type: 'Default',
            cssClass: "e-icon e-mail e-reportviewer-icon subCustomGroup",
            id: 'subCustomGroup',
            tooltip: { header: 'subCustomGroup', content: 'subtoolbargroups' }
            }],
        groupIndex: 3
    }]
}

  //Toolbar click event handler
function onToolBarItemClick(event) {
    if (event.value === "CustomGroup") {
        //Implement the code to CustomGroup toolbar option
        alert("CustomGroup toolbar option clicked");
    }
    if (event.value === "subCustomGroup") {
        //Implement the code to subCustomGroup toolbar option
        alert("SubCustomGroup toolbar option clicked");
    }
}

function App() {
  return (
    <div style={viewerStyle} className="App">
            <BoldReportViewerComponent
            id="reportviewer-container"
            serviceUrl={'https://demos.boldreports.com/services/api/ReportViewer'}
            reportPath = {'~/Resources/docs/sales-order-detail.rdl'}
            toolbarSettings = {toolbarSettings}
            toolBarItemClick = {onToolBarItemClick}>
            </BoldReportViewerComponent>
    </div>
  );
}