Intersoft ClientUI Documentation
SqlReportViewer

SqlReportViewer is a specialized implementation of UXDocumentViewer designed to work with Microsoft SQL Server 2008 Reporting Services document. SqlReportViewer includes sophisticated parsing and layout rendering implementation which presents the report identical to the design. In addition, it also features automatic pagination capability which renders the report based on the paper size defined in the report. This behavior is similar to the PDF export result in the SQL Server Reporting Services (further abbreviated as SSRS). To learn more about SQL Reporting Services, please visit MSDN Library.

SqlReportViewer supports SQL reporting service actions such as Toggle item, Go to report, Go to bookmark, and Go to URL, as well as exporting. The supported export formats in SQL reporting service, such as XML, CSV, PDF, HTML, Excel, and Word, are well supported in SqlReportViewer.

SqlReportViewer Overview

SqlReportViewer Overview

SqlReportViewer is an advanced and feature-rich report viewer control which renders SSRS reports with identical layout and appearance as the report design. It supports most report items available in SSRS such as TextBox, Line, Image as well as comprehensive support for Matrix, Table and List (Tablix). SqlReportViewer supports both Silverlight and WPF platforms equipped with key features such as pixel-perfect document rendering, search and highlight matching words, text selection, copy to clipboard, navigate to page, background loading and printing support.

In addition, SqlReportViewer also features historical journal navigation using the back and forward toolbar button. Toggle item and goto report actions will automatically add an entry to the historical navigation list.

The following table lists the supported SQL reporting service control.

Report Item Feature Description
TextBox Most features are supported, except certain font style which is not supported in Silverlight, i.e., Strikethrough.
Minor layout differences when using AutoGrow option.
Line All features are supported.
Table All features are supported.
Matrix All features are supported.
Rectangle All features are supported.
List All features are supported.
Image All features are supported. GIF and TIFF image is not supported by Silverlight.
Sub Report All features are supported.
Chart Supported using rendering extension.
Gauge Supported using rendering extension.
Map Supported using rendering extension.
Data Bar Supported using rendering extension.
Sparkline Supported using rendering extension.
Indicator Not supported.

As shown in the table above, most report items in SSRS are natively supported in the SqlReportViewer control. However, some controls such as Chart, Map, and Gauge are not rendered by default. To render these controls, a custom rendering class must be implemented such as described in How-to: Extending SqlReportViewer Rendering Engine.

Using SqlDocumentViewer

SqlReportViewer shares many common features with UXDocumentViewer such as rich navigation support, zoom presets, text selection, search, localization and printing. To learn about these shared features in details, please refer to UXDocumentViewer Overview.

In addition, SqlReportViewer provides a number of advanced features to work with SQL reporting service report such as background loading feature which is designed to handle relatively large report, report navigation, and report browser.

Before you can use SqlReportViewer, you need to first register the rendering extension and configure the server-side settings such as handlers and service points. To get started, please see Walkthrough: Configuring SqlReportViewer for First Time Use.

The following example shows the XAML code to display a SSRS report in SqlReportViewer.

View
Copy Code
<Intersoft:SqlReportViewer ReportProxyHandler="http://adventureworks.com/SqlReportViewerHandler.ashx" 
                           ReportServer="http://localhost/ReportServer" 
                           ReportName="/Customers Report" />

Before you can use SqlReportViewer to display a report, you need to first design the report using either Report Builder or Visual Studio tools for SSRS. The following illustration shows the design-time environment for SSRS and the viewer results in the SqlReportViewer. To learn more about designing report in SSRS, please visit MSDN Library.

Understanding SqlReportViewer Elements

SqlReportViewer facilitates users with the capability to view, search, and navigate a SQL report. To achieve these capabilities, SqlReportViewer comes with rich user interface elements that consisted of UXResizablePane, UXNavigationPane, UXVirtualizingListBox, UXTreeView, UXSearchBox, UXToolBar and UXStatusBar.

The following figure illustrates the rich user interface elements of SqlReportViewer in details.

SqlViewer Layout

The top illustration shows the control's elements with the navigation pane expanded, while the bottom illustration shows the control's elements with the navigation pane minimized.

Although the SqlReportViewer already provides predefined UI elements to allow rich user interaction, you are free to customize any of the elements to suit your application's preferences – thanks to the loosely-coupled architecture design that made the customization possible. You can customize the styles and appearance of the elements entirely by editing the control template using designer tools such as Expression Blend. To learn more about the commands used in the predefined UI elements, see the SqlReportViewer Commands section later in this topic.

Configuring Report Browser Feature

Report browser feature automatically load the list of available report in the report server. By default this feature is enabled. However, user has the option to disable the feature by setting EnableAutomaticListFetching property to False.

SqlViewer Report Browser
You can also define the custom report list by adding a new SQLReportMetadata instance to the report collection which is accessible through the ReportNavigationList property.

Configuring Loading Mode

SqlReportViewer supports three loading strategies such as discussed below.

By default, SqlReportViewer is set to use load-on-demand mode which means that only pages visible in the document will be rendered. The rest of pages will be rendered when they become visible in the view due to user interactions, for instances, through page scrolling or outline navigation. Depending on your scenario, you may wish to load all pages in SqlReportViewer initially which can be achieved by setting the LoadingMode property value to All.

Another available loading strategy is Streaming mode which only load and render the visible pages in the document.

Enabling Background Loading

Designed for performance, SqlReportViewer is capable in handling large SQL report without performance bottleneck, thanks to the innovative background loading feature. Background loading allows pages to be preloaded in the background during application's idle time. This means that the background loading will pause the process when it detects user's activities such as mouse movement or key press.

The idle latency can be customized through the IdleLatency property which is set to 3 seconds by default. You can disable this feature by setting the EnableBackgroundLoading property value to False.

Configuring Report Parameters

Comprehensive report parameter support is available in the SqlReportViewer control. The parameter panel will be automatically displayed with the respective parameters defined in the SSRS report. Based on the parameter type defined, SqlReportViewer will use different input control to match the defined parameter type.

The following table describes the control associated to each parameter type.

Data Type Control
Text UXTextBox
Boolean UXCheckBox
Date/Time UXDateTimeEditor
Integer UXNumericUpDown
Float UXCurrencyEditor
If predefined values are available in the report, SqlReportViewer will use UXComboBox control to display the options.

SqlReportViewer also includes built-in validation for required parameters, i.e., the parameters which AllowBlank and AllowNull properties are set to False in the report. When the Submit button is clicked, the required parameters will be automatically validated. A validation error message when be displayed for each required parameter that has not been filled. Also note that Boolean type parameter is considered as False by default.

SqlViewer Validation

SqlReportViewer also exposes a command, set through the SubmitParameterCommand property, which will be invoked when the Submit button is clicked. The submit action will be executed when the IsReportParameterError property value is true.

The collection of currently displayed report parameters object can be obtained from the ReportParameters property. You can extend the parameter by implementing ISqlParameterMetadata interface and overwriting the ReportParameters property.

Extending SqlReportViewer Rendering Engine

As explained in the previous topics, some report items require rendering engine extension in order to be rendered successfully in the SqlReportViewer. These controls are:

The provided rendering engine extension for the controls are:

ChartRenderer Responsible for Chart, Data Bar, and Sparkline control.
MapRenderer Responsible for Map control.
GaugeRenderer Responsible for Gauge control.

Each renderer provides two override functions which should be implemented to successfully render the conttrol representation in SqlReportViewer:

By default, without extending rendering engine, the control is rendered as a text placeholder as shown in the left image below.

SqlViewer Rendering Engine Extension

Extending chart rendering engine using Silverlight toolkit assembly will result in the right image. For more detailed explanation about rendering engine extension, see How-to: Extending SqlReportViewer Rendering Engine.

Using SqlReportViewer to Display Multiple Reports

SqlReportViewer is designed to handle numerous reporting scenarios such as single report scenario and multiple report scenario. To learn more about the scenarios, see the topics below.

Localizing SqlReportViewer

SqlReportViewer provides full localization support for the textual content used in the user interface elements. The following table lists the localizable string resources.

Toolbar
GoBackText Back
GoForwardText Forward
PrintText Print
CopyText Copy [Also used in context menu.]
ExportPdfText PDF
ExportExcelText Excel
ExportWordText Word
ExportOtherText Export to other formats
ExportHtmlText MHTML (Web Archive)
ExportImageText JPEG Image
ExportXmlText XML
ExportCsvText CSV
ActualSizeText Show Actual Size
FitHeightText Fit Page to Height
FitWidthText Fit Page to Width
FullScreenText Toggle Full Screen
ShowNavigationPaneText Show/Hide Navigation Pane
SearchWatermarkText Find
PreviousSearchText Previous Match
NextSearchText Next Match
Navigation Pane
NavigationHeaderText Navigation Pane
ThumbnailsText Thumbnails
ReportListText Report List
RefreshText Refresh
Report Parameter Window
ReportParametersText Report Parameters
EmptyParameterText Value must not be empty
SubmitText Submit
Status Bar
PreviousPageText Previous Page
NextPageText Next Page
ChangeZoomLevelText Change Zoom Level
ZoomInText Zoom In [Also used in context menu.]
ZoomOutText Zoom Out [Also used in context menu.]
Context Menu
ContextMenu_PrintText Print...
DocumentViewers Status
SearchingText Searching page {0}
PrintingDocumentText Printing document...
LoadingText Loading page {0}.
ReadyText Ready.
LoadingReportLinksText Loading report list
FetchingDataText Loading {0}...

SqlReportViewer Toolbar

SqlReportViewer provides comprehensive commands for rich viewing experiences. Many of the essential commands are presented as command buttons in the toolbar and status bar section of the control. The complete elements can be seen in the section above.

The following table lists the commands presented in the toolbar section of the SqlReportViewer control.

Report Navigation
GoBack Navigate to the previous report in the history.
GoForward Navigate to the next report in the history.
Export
XML Export displayed report to XML format.
CSV Export displayed report to CSV format.
PDF Export displayed report to PDF format.
HTML Export displayed report to HTML 4.0 format.
IMG Export displayed report to JPEG image format.
Excel Export displayed report to Microsoft Excel format.
Word Export displayed report to Microsoft Word format.
Page Navigation
PageBox Displays the current page shown in the content section and the total page count of the document. You can enter a page number to directly jump to the specific page.
PreviousPage Scroll to the previous page in the document.
NextPage Scroll to the next page in the document.
ToggleThumbnails Show or hide the navigation section.
ShowThumbnails Sets the navigation mode to Thumbnails.
ReportLinks Sets the navigation mode to Report Links.
Page Zooming
ActualSize Sets the zoom mode to show the actual size of the document.
FitWidth Sets the zoom mode to fit the width of the document.
FitHeight Sets the zoom mode to fit the height of the document.
ZoomButton
ZoomSlider
Magnify the document size by a preset ratio.
Search
SearchBox TextBox to fill in the search criteria.
Others
FullScreen Toggle the SqlReportViewer control to fill the screen.
Print Print the document using print file dialog.
Copy Copy the highlighted text.
Refresh Reload the report list from the report server.

SqlReportViewer Commands

SqlReportViewer is built around the commanding semantics which allows the document interaction to be executed through declarative definition in the XAML markup. The commanding semantics is also an ideal approach for MVVM pattern development.

In addition to the commands in UXDocumentViewer, SqlReportViewer also includes predefined commands to interact with the report document which are described in the following table.

Commands Description
GoToLink Represents the command to navigate to URI supplied in parameter. The URI could be an internal link or a new report.
ToggleItem Represents the command to toggle item visibility, based on SQL Reporting Service action.
NavigateBackwardCommand Represents the command to navigate to the previous report in history.
NavigateForwardCommand Represents the command to navigate to the next report in history.
ExportReportCommand Represents the command to export a report to a predefined format based on the parameter supplied. i.e. XML, CSV, PDF, HTML4.0, EXCEL, IMAGE, and WORD.
OpenReportCommand Represents the command to open a report based on SqlReportNavigationLink parameter.
FetchReportLinksCommand Represents the command to load the available report list in the report server.
See Also