To render SharePoint server reports set the reportServerUrl
, reportPath
, and reportServiceUrl
properties as in the following code snippet.
<div style="height: 100%; width: 100%;">
<div style="height: 600px; width: 950px; min-height: 400px;" id="viewer"></div>
<script type="text/javascript">
$(function () {
$("#viewer").boldReportViewer({
reportServiceUrl: "/api/SharePointReports",
reportPath: "http://<servername>/reportserver$instanceName/SSRSSamples/Territory Sales.rdl",
reportServerUrl: "http://<servername>/reportserver$instanceName"
});
});
</script>
</div>
You can view the Web API service used in the above code from the Reporting Service git hub location. For more information, see Samples and demos. In SharePoint integrated mode, the
reportServerUrl
will be same as your site URL. ThereportPath
is relative to the Report Server URL with the file extension.
The Forms credentials are required to connect with the specified SharePoint integrated SSRS Report Server using the Report Viewer. Specify the ReportServerFormsCredential
property in the Web API Controller OnInitReportOptions
method.
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
//Add ReportServerFormsCredential for server
reportOption.ReportModel.ReportServerFormsCredential = new BoldReports.Web.ReportServerFormsCredential("ssrs", "RDLReport1");
}
The shared data source credentials can be added to the DataSourceCredentials
property to connect with the database.
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
//Add ReportServerFormsCredential and data source credentials
reportOption.ReportModel.ReportServerFormsCredential = new BoldReports.Web.ReportServerFormsCredential("ssrs", "RDLReport1");
reportOption.ReportModel.DataSourceCredentials.Add(new BoldReports.Web.DataSourceCredentials("<database>", "ssrs1", "RDLReport1"));
}
Data source credentials must be added for shared data sources that do not have credentials in the connection strings.
Build and run the application. Preview and edit the result using the following.
$(function () {
$("#viewer").boldReportViewer({
reportServiceUrl: "https://demos.boldreports.com/services/api/SharePointReports",
reportPath: "http://<servername>/reportserver$instanceName/SSRSSamples/Territory Sales.rdl",
reportServerUrl: "http://<servername>/reportserver$instanceName"
});
});
[NonAction]
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
//Add ReportServerFormsCredential and data source credentials
reportOption.ReportModel.ReportServerFormsCredential = new BoldReports.Web.ReportServerFormsCredential("ssrs", "RDLReport1");
reportOption.ReportModel.DataSourceCredentials.Add(new BoldReports.Web.DataSourceCredentials("<database>", "ssrs1", "RDLReport1"));
}