How to Open an Existing Server Report in Bold Reports Designer for Angular
When initializing the Bold Reports Designer, you can open an existing report from the server by utilizing the create API event and the openReport API method. This can also serve as an alternative solution for the Template report where you can open the previously created report design as a template report.
- If you plan to use the code sample provided in this article, ensure that jQuery is available in your Angular application because the example uses the $() function to access the Report Designer instance.
Example installation:
npm install jquery
npm install --save-dev @types/jquery
- In your TypeScript file:
declare var $: any;
Follow the steps below to open the server report using the report path when opening the Report Designer:
Step 1: Configure the Report Designer
- Create a function in the app.component.ts and bind it with the create API Event in the app.component.html file as in the following code sample.
app.component.html:
<bold-reportdesigner
id="reportDesigner_Control"
[serviceUrl]="serviceUrl"
[reportServerUrl]="reportServerUrl"
[serviceAuthorizationToken] = "serverServiceAuthorizationToken"
(create)="controlInitialized()"
style="position: absolute;height: 550px; width: 1250px;">
</bold-reportdesigner>
Obtaining the Service Authorization Token
The
serviceAuthorizationTokenproperty must be assigned a valid Service Authorization Token generated through the Report Server authentication process. Ensure that the token belongs to a user account with sufficient permissions to access and modify the target report. For production environments, it is recommended to generate and assign the token dynamically rather than hardcoding it in the application.
app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
public serviceUrl: string;
public serverServiceAuthorizationToken: string;
public reportServerUrl: string;
constructor() {
this.reportServerUrl = 'https://on-premise-demo.boldreports.com/reporting/api/site/site1';
this.serviceUrl ='https://on-premise-demo.boldreports.com/reporting/reportservice/api/Designer';
this.serverServiceAuthorizationToken = 'bearer {service_authorization_token}';
public controlInitialized() {
// Open the existing report after the Report Designer has been initialized.
}
}
Note: The controlInitialized() function was bound with create API.
Step 2: Open an Existing Report
- The controlInitialized() function is bound to the Report Designer’s create event and is executed after the designer has been initialized. Use the openReport API method in the function along with the report path that was previously created, as shown in the following code sample.
app.component.ts:
public controlInitialized() {
let designerObject: any = $('#reportDesigner_Control').data('boldReportDesigner');
designerObject.openReport('/Sample Reports/Company Sales');
}
Notes
-
jQuery requirement:
- This example uses
jQuery ($)to retrieve the Bold Reports Designer instance. Ensure thatjQueryis added to your Angular application before using this code sample.
- This example uses
-
Understanding the report path:
- In this example, “Sample Reports” is the category name and “Company Sales” is the report name that is passed in the openReport API method as part of the report path.
-
Accessing the Report Designer instance:
- In the app.component.ts file, utilize the ID “reportDesigner_Control” in the controlInitialized() function to access the Bold Reports Designer. Ensure that this ID matches exactly with the one used in the < bold-reportdesigner > tag in app.component.html.
- After accessing the Report Designer, the report associated with the specified path is opened automatically.
You can find the following help documentation on how to open an existing server report in Bold Reports Designer on various platforms:
See also: