The page describes the Blazor Viewer API that can be used for initialization or at run time while working with the viewer.
RenderMode
Description: The initial render mode - 'Paginated' or 'Galley'. The default value is 'Paginated'.
Type: Enum: RenderMode
Accepted values: 'RenderMode.Paginated', 'RenderMode.Galley'
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" RenderMode="RenderMode.Paginated"/> |
DefaultExportSettings
Description: The object containing custom default export settings. Use to preset the export settings' default value and its visibility in the export panel.
Type: Dictionary<string, Dictionary<string, ExportSetting>>
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DefaultExportSettings="@defaultExportSettings"/> @code{ Dictionary<string, Dictionary<string, ExportSetting>> defaultExportSettings = new Dictionary<string, Dictionary<string, ExportSetting>>() { { "xls", new Dictionary<string, ExportSetting>(){ { "FileName", new ExportSetting() {Value = "ar16", Visible = true} }, { "EnableToggles", new ExportSetting() {Value = false} } } } }; } |
AvailableExports
Description: The array of export types available via export functionality of the viewer.
Type: ExportTypes[]
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" AvailableExports="availableExportArr"/> @code{ ExportTypes[] availableExportArr = new ExportTypes[] { ExportTypes.Pdf, ExportTypes.Xlsx, ExportTypes.Xls, ExportTypes.Json }; } |
Locale
Description: The locale used for displaying the viewer.
Type: String
Accepted values: 'en-US' (for English), 'ja-JP' (for Japanese), and 'zh-CN' (for Chinese)
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Locale="ja-JP"/> |
LocaleData
Description: The JSON containing the localization strings.
Type: String
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" LocaleData="@_localeData" > @code{ string _localeData = "{\"viewer\": {\"toolbar\": {\"refresh\": \"更新\"} } }"; } |
LocaleUri
Description: The url of the file containing the localization strings.
Type: String
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" LocaleUri="localization.json"/> |
PanelsLocation
Description: The location of the panels (search panel, parameters panel, etc.) to the left side ('toolbar') or the right side ('sidebar') of the viewer. The default value is 'toolbar'.
Type: Enum: PanelsLocation
Accepted values: 'PanelsLocation.sidebar', 'PanelsLocation.toolbar'
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" PanelsLocation="PanelsLocation.toolbar" /> |
DisplayMode
Description: Set the single page or continuous page mode for the viewer.
Type: Enum: ViewMode
Accepted values: 'ViewMode.Single', 'ViewMode.Continous'
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DisplayMode="ViewMode.Single" /> |
Action
Description: The callback that is invoked before the viewer opens the hyperlink, bookmark link, drill-down report, or toggles the report control visibility.
Type: Method (string, object[])
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Action="actionMethod" /> @code{ public void actionMethod(string actionType , object[] actionParams) { System.Diagnostics.Debug.WriteLine(actionType); foreach(var obj in actionParams) { System.Diagnostics.Debug.WriteLine(obj); } } } |
Error
Description: The callback that is invoked when an error occurs in the process of displaying the report.
Type: Method(ErrorInfo obj)
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Error="errorMethod" /> @code{ public void errorMethod(ErrorInfo obj) { System.Diagnostics.Debug.WriteLine("Error Message :" + obj.Message); } } |
HideErrors
Description: Specify whether to show errors in the viewer ('false' by default).
Type: bool
Accepted values: 'true', 'false'
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" HideErrors="true" /> |
DocumentLoaded
Description: The callback that is invoked when a document is loaded entirely on the server.
Type: Method()
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="DocumentLoaded"/> @code{ public void DocumentLoaded() { System.Diagnostics.Debug.WriteLine("Document Loaded"); } } |
ReportService
Description: Set up the settings to connect the Web API.
Type: ReportServiceSettings object
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ReportService="setting" /> @{ ReportServiceSettings setting = new ReportServiceSettings() { Url = "http:example.com/api/reporting", SecurityToken = "security_Token", OnRequest = (OnRequestInfo obj) => { obj.Headers.Add("Authorization", "security_Token"); } }; } |
ViewerInitialized
Description: The callback that is invoked when the viewer is initialized
Type: Method()
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ViewerInitialized="InitializedViewer"/> @code{ private void InitializedViewer() { System.Diagnostics.Debug.WriteLine("Viewer is initailized now"); } } |
ReportLoaded
Description: The callback that is invoked when the viewer obtains the information about the requested report.
Type: Method(ReportInfo obj)
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ReportLoaded="ReportLoaded"/> @code{ public void ReportLoaded(ReportInfo obj) { System.Diagnostics.Debug.WriteLine("The report " + obj.Name + " was successfully loaded!"); } } |
ParametersPanelSettings
Description: Set up the parameters panel settings.
Type: ParametersPanelSettings object
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ParametersPanelSettings="parametersPanelSetting"/> @code{ ParametersPanelSettings parametersPanelSetting = new ParametersPanelSettings() { Location = ParameterPanelLocation.Default }; } |
Sidebar
Description: The viewer's sidebar instance. Use it to toggle the sidebar visibility.
Returns: Sidebar object
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ViewerInitialized="InitializedViewer"/> @{ private ReportViewer _viewer; private void InitializedViewer() { Sidebar obj = _viewer.Sidebar; } } |
Parameters
Description: The array of the {name, value} pairs that describe the values of the parameters used to run the report.
Type: Parameter[]
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Parameters="parameterArray"/> @code{ Parameter[] parameterArray = new Parameter[] { new Parameter { Name = "Category", Values = new string[]{"Business" } } }; } |
ReportName
Description: The name of the report to be shown by the viewer.
Type: String
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" /> @code{ private ReportViewer _viewer; private string _currentReport = null; protected override void OnInitialized() { reportsList = ReportsService.GetReports().ToList(); _currentReport = reportsList.FirstOrDefault(); } } |
Width
Description: The width of the viewer, by default 100%.
Type: String
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Width="50%"/> |
Height
Description: The width of the viewer, by default 100%.
Type: String
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" Height="50%"/> |
Toolbar
Description: The viewer's toolbar instance. Use it to add the custom elements or remove the existing ones.
Returns: Toolbar object
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ViewerInitialized="InitializedViewer"/> @{ private ReportViewer _viewer; private void InitializedViewer() { Toolbar obj = _viewer.Toolbar; } } |
BackToParrent
Description: Makes the viewer to display the parent report of the drill-down report.
Type: Method
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" ViewerInitialized="InitializedViewer"/> @code{ private ReportViewer _viewer; private void InitializedViewer() { await _viewer.BackToParrent(); } } |
CurrentPage
Description: The currently displayed page number.
Type: Method
Returns: ValueTask<int>
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { var currentPage = await _viewer.CurrentPage(); System.Diagnostics.Debug.WriteLine(currentPage); } } |
Export
Description: Exports the currently displayed report.
Parameters:
Type: Method(ExportTypes, Action<string> callback = null, bool = false, Dictionary<string, string> settings = null, Func<bool> isCancelRequested = null, )
Returns: Void
Sample code |
Copy Code
|
---|---|
<GrapeCity.ActiveReports.Blazor.ReportViewer @ref="_viewer" ReportName="@reportId" DocumentLoaded=" @DocumentLoaded"/> @code { private ReportViewer _viewer; private string reportId = "User defined report columns.rdlx"; private async void DocumentLoaded() { await _viewer.Export(ExportTypes.Pdf, (uri) => { //uri to export result }, false, new Dictionary<string, string>() { { "Title", "Some Title" } }, () => { //hecking export cancellation return false; } ); } } |
GetToc
Description: Obtains the report TOC.
Type: Method
Returns: ValueTask<BookmarkInfo>
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { var toc = await _viewer.GetToc(); } } |
GoToPage
Description: Makes the viewer display the specific page. Page numeration starts with 1.
Type: int
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { await _viewer.GoToPage(2); } } |
OpenReport
Description: Makes the viewer to display the parent report of the drill-down report.
Type: Method(string, Parameter[] = null)
Returns: Void
Sample code |
Copy Code
|
---|---|
_viewer.OpenReport("TestReport.rdlx"); OR Parameter[] parameterArray = new Parameter[] { new Parameter { Name = "Category", Values = new string[]{"Business" } } }; _viewer.OpenReport("TestReport.rdlx", parameterArray); |
PageCount
Description: Gets the page count of the currently displayed report.
Type: Method
Returns: ValueTask<int>
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { var countPage = await _viewer.PageCount(); System.Diagnostics.Debug.WriteLine(countPage); } } |
Description: Prints the currently displayed report if any.
Type: Method()
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { await _viewer.Print(); } } |
Refresh
Description: Refreshes the report preview.
Type: Method()
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { await _viewer.Refresh(); } } |
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.
Parameters:
Type: Method(string, SearchOptions = null, Action<List<SearchResult>> = null)
Returns: Void
Sample code |
Copy Code
|
---|---|
<ReportViewer @ref="_viewer" ReportName="@_currentReport" DocumentLoaded="@DocumentLoaded"/> @code{ private async void DocumentLoaded() { //Searching ALFKI keyword in the report await _viewer.Search("ALFKI", new SearchOptions() { MatchCase = true, WholePhrase = false }, (List<SearchResult> results) => { if (results != null && results.Count > 0) { foreach (var res in results) { System.Diagnostics.Debug.WriteLine(res.DisplayText); } } }); } |