New to Telerik ReportingStart a free 30-day trial

The data attributes of the HTML5 Report Viewer

Behavior can be added to HTML DOM elements either with data- attributes or through the commands property of the report viewer.

The data- attributes allow for adding flexibility to the application since commands can be attached to HTML elements only by adding a data-command attribute along with a data-target-report-viewer to target the specific report viewer (since there can exist multiple report viewers on a single page):

HTML
<button id="printButton" data-command="telerik_ReportViewer_print" data-target-report-viewer="#reportViewer1">Print report</button>

When initializing the report viewer, the selector used in data-target-report-viewer has to be explicitly provided as an option:

JavaScript
$("#reportViewer1").telerik_ReportViewer({
	serviceUrl: "api/reports/",
	reportSource: { report: "Product Catalog.trdx" },
	selector: '#reportViewer1'
});

The button above will print the currently displayed report. Elements do not need to exist before the viewer initialization - they can be created on the fly, and as soon as they have the data-command and data-target-report-viewer attributes, the command can be executed.

The following table is a list of all available commands for the data-command attribute:

CommandDescription
telerik_ReportViewer_historyBackGo back to the previously rendered report (can be the same report with different parameters for example)
telerik_ReportViewer_historyForwardGo forward to the next rendered report (can be the same report with different parameters for example)
telerik_ReportViewer_stopRenderingStop the report rendering
telerik_ReportViewer_refreshRefresh the report
telerik_ReportViewer_goToFirstPageGo to the first page of the report
telerik_ReportViewer_goToPrevPageGo to the previous page of the report
telerik_ReportViewer_goToNextPageGo to the next page of the report
telerik_ReportViewer_goToLastPageGo to the last page of the report
telerik_ReportViewer_togglePrintPreviewToggle between Print Preview and Interactive modes
telerik_ReportViewer_exportExport the report, using the respective data-command-parameter *
telerik_ReportViewer_printPrint the report
telerik_ReportViewer_toggleDocumentMapShow or hide the document map
telerik_ReportViewer_toggleParametersAreaShow or hide the parameters area
telerik_ReportViewer_zoomInZoom in the report
telerik_ReportViewer_zoomOutZoom out the report
telerik_ReportViewer_toggleZoomModeChange the zoom mode of the report
telerik_ReportViewer_toggleSideMenuShow or hide the side menu
telerik_ReportViewer_toggleSearchDialogShow or hide the search dialog

The export command requires one additional parameter, data-command-parameter, which will specify the export format. The full list of all allowed data-command-parameter values is as follows:

LabelCommand Parameter
Adobe (PDF) filePDF
CSV (comma delimited)CSV
Excel 97-2003XLS
Excel WorksheetXLSX
PowerPoint PresentationPPTX
Rich Text FormatRTF
TIFF FileIMAGE
Web ArchiveMHTML
Word DocumentDOCX
XPS DocumentXPS

Depending on the report and the history of browsed reports, some of the buttons may be disabled, and others may be toggled. The commands automatically keep track of their state, but if custom widgets are used, this state will not be displayed properly. Therefore, a disabledButtonClass and checkedButtonClass can be provided to the report viewer upon initialization - these classes will be added when the custom button is disabled or toggled, respectively.

See Also

In this article
See Also
Not finding the help you need?
Contact Support