The following options can be set during initialization or at run time while working with the HTML5 Viewer.
uiType
Description: Sets the UI mode of the HTML5 Viewer.
Type: String
Accepted Value: 'Custom', 'Mobile' or 'Desktop'
Example:
viewer.option('uiType', 'Mobile');
element
Description: JQuery selector that specifies the element that hosts the HTML5 Viewer control.
Type: String
Example:
var viewer = GrapeCity.ActiveReports.Viewer(
{
element: '#viewerContainer2',
reportService: {
url: '/ActiveReports.ReportService.asmx'
},
});
reportService
Description: The report service that can use ActiveReports Web Report Service.
Type: Object that has the url and optional securityToken properties
Example:
reportService: {
url: '/ActiveReports.ReportService.asmx'
};
reportService.url
Description: The ActiveReports Web service url that provides the reportInfo and output.
Type: String
Example:
reportService: {
url: '/ActiveReports.ReportService.asmx'
};
report
Description: The report that is displayed in ActiveReports Web Report Service.
Type: An object that has id and parameters properties.
Example:
report: {
id: 'CustomersList',
parameters: [
{
name: 'CustomerID',
value: 'ALFKI'
}]
};
reportID
Description: The id of the report to be shown by the HTML5 Viewer.
Type: String
Example:
Example:
report: {
id: 'CustomersList',
parameters: [
{
name: 'CustomerID',
value: 'ALFKI'
}]
};
reportParameters
Description: The array of the {name, value} pairs that describe the parameters values used to run the report.
Type: Array
Example:
For single value parameter:
report: {
id: 'CustomersList',
parameters: [
{
name: 'CustomerID',
value: 'ALFKI'
}]};
For multi-value parameter as array:
var arrParam = [1, 2, 3];
var reportOption = {
id: 'PageReport1.rdlx',
parameters: [
{
name: 'Parameter1',
values: arrParam,
multivalue: true
}]
};
viewer.option('report', reportOption);
reportLoaded
Description: The callback that is invoked when the HTML5 Viewer obtains the information about the requested report. The reportInfo object is passed in the callback including the TOC info, Parameters info and the link to the rendered report result.
Type: function(reportInfo)
Example:
var reportLoaded = function reportLoaded(reportInfo)
{
console.log(reportInfo.parameters);
}
viewer.option('reportLoaded', reportLoaded);
action
Description: The callback that is invoked before the HTML5 Viewer opens the hyperlink, bookmark link, drill down report or toggles the report control visibility.
Type: function(actionType, actionParams)
Example:
function onAction(actionType, actionParams)
{
if (actionType === 0)
{
window.open(params.url, "Linked from report", "height=200,width=200");
}
}
viewer.option('action', onAction);
availableExports
Description: The array of export types available via Export functionality of HTML5 Viewer. By default, PDF, Word, Image, Mht, Excel, and CSV exports are available.
Type: Array
Example:
viewer.option("availableExports", ['Pdf']);
maxSearchResults
Description: The number of search results received for a single search invoke.
Type: Number
Example:
maxSearchResults: 10
error
Description: The callback that is invoked when an error occurs in the process of displaying the report. The default error panel does not appear if the callback returns true. The error parameter is an object that has a message property which allows the users to customize the error message.
Type: function(error)
Example: To hide the default error panelExample: To customize the error messagevar options = {
error: function(error){
if (error.message) {
// show error message.
alert("Internal error! Please ask administrator.");
return true; // do not show default error message.
}
},
// other properties. }; var viewer = GrapeCity.ActiveReports.Viewer(options);
var options = {
error: function(error){
error.message = "My error message";
},
// other properties
};
var viewer = GrapeCity.ActiveReports.Viewer(options);
documentLoaded
Description: The callback that is invoked when a document is loaded entirely on the server.
Type: function()
Example:var documentLoaded = function documentLoaded()
{
setPaginator();
}
viewer.option('documentLoaded', documentLoaded);
localeUri
Description: The url of the file containing the localization strings.
Type: String
Example:
var viewer = GrapeCity.ActiveReports.Viewer(
{
localeUri: 'Scripts/i18n/ru.txt'
});
showOnlyLastError
Description: Removes the Show Details button in the error panel and shows only the last error.
Type: String
Example: To hide the Show Details button
var viewer = GrapeCity.ActiveReports.Viewer({
showOnlyLastError: true
});
displayMode
Description: Set up single page or continuous page.
Type: String
Accepted Value: 'single', 'continuous'
Example:
viewer.option('displayMode', 'continuous');
previewPages
Description: Specify the maximum number of report pages to be rendered on HTML5Viewer while previewing RDL or Page reports.
Type: Integer
Example:
previewPages: 6
After initializing the HTML5 Viewer, the following API methods and properties can be used.
option
Description: Gets or sets the option value by name if the value parameter is specified.
Syntax: option(name,[value])Object
Parameters:
viewer.option('uiType', 'mobile');
viewer.option('report', {
id: 'my report'
});
viewer.option('displayMode', 'continuous');
Return Value: The current option value.
refresh
Description: Refreshes the report preview.
Syntax: option(name,[value])Object
viewer.refresh()
Return Value: Void
Description: Prints the currently displayed report if any.
Syntax: print()Void
viewer.print()
Return Value: Void
goToPage
Description: Makes the viewer to display the specific page, scroll to the specific offset (optional) and invokes the callback once it's done.
Syntax: goToPage(number, offset, callback)Void
Parameters:
viewer.goToPage(1, {
2, 3
}, function onPageOpened()
{});
Return Value: Void
backToParent
Description: Makes the viewer to display the parent report of the drill-down report.
Syntax: backToParent()Void
viewer.backToParent()
Return Value: Void
destroy
Description: Removes the viewer content from the element.
Syntax: destroy()Void
viewer.destroy()
Return Value: Void
export
Description: Exports the currently displayed report.
Syntax: export(exportType,callback,saveAsDialog,settings)Void
Parameters:
Example:
function exportToExcel()
{
viewer.export('Xls', downloadReport, true, { FileName: "DefaultName.xls" });
}
// function fetches the report from uri(callback function)
var downloadReport = function (uri) {
var newWin = null;
// open uri in new window
try {
newWin = window.open(uri);
} catch (e) { }
// if browser rejects opening new window, open uri in current window
if (!newWin) {
window.location = uri;
}
};
Return Value: Void
search
Description: Performs the search of a specific term with specific search options (match case, whole word) and invokes the specific callback with the search result passed.
Syntax: search(searchTerm, searchOptions, callback)Void
Parameters:
viewer.search('a', {
matchCase: true,
wholePhrase: false
}, function (results)
{
console.log(results);
});
Return Value: Void
getToc
Description: Obtains the part of the report TOC specified by parent(node), startChild(index), count parameters and invokes callback function passing the result as parameter.
Syntax: getToc(callback) Void
Parameters:
viewer.getToc(function (toc)
{
console.log(toc);
})
Return Value: Void
pageCount
Description: Gets the page count of the currently displayed report.
Syntax: viewer.pageCount
console.log(viewer.pageCount)
Return Value: An integer representing page count.
currentPage
Description: Gets the currently displayed page number.
Syntax: viewer.currentPage
console.log(viewer.currentPage)
Return Value: An integer representing currently displayed page number.
Toolbar
Description: Returns the HTML element that displays the toolbar in desktop UI mode. The developer may use it to add the custom elements or remove the existing ones using jQuery/Html/Css capabilities.
Syntax: viewer.Toolbar
// Toolbar, MobileToolbarTop, MobileToolbarBottom
$(viewer.toolbar).hide();
$(viewer.toolbarTop).hide();
$(viewer.toolbarBottom).hide();
ToolbarTop
Description: Returns the HTML element that displays the top toolbar in mobile UI mode.
Syntax: viewer.ToolbarTop
// Toolbar, MobileToolbarTop, MobileToolbarBottom
$(viewer.toolbar).hide();
$(viewer.toolbarTop).hide();
$(viewer.toolbarBottom).hide();
ToolbarBottom
Description: Returns the HTML element that displays the bottom toolbar in mobile UI mode.
Syntax: viewer.ToolbarBottom
// Toolbar, MobileToolbarTop, MobileToolbarBottom
$(viewer.toolbar).hide();
$(viewer.toolbarTop).hide();
$(viewer.toolbarBottom).hide();