I have a report that gives the nutrient breakdown of a feed ingredient. Sometimes the users in the lab will name the ingredient such that it references other work they are performing which typically results in the use of special characters. When they use "{}" the report viewer throws an exception.
I know that there is a workaround in C# to resolve these conflicts but how do I get around this in the Telerik Reporting system (short of scrubbing the data to remove the offending character?) The Value assignment in the example code causes this issue.
Example code:
<TextBox Width="1.78in"
Height="0.17in"
Left="0in"
Top="1.96in"
Value="{35 DM NDF M}"
Name="lblDietSummary_Title_0">
<Style Visible="True"
Color="Black"
TextAlign="Left"
VerticalAlign="Middle">
<Font Name="Arial"
Size="9pt"
Bold="True" />
</Style>
</TextBox>
Hello,
I have an ASP.NET MVC web application with several modules.
I would like to add a new statistics module contains multiple reports and only use the view part in this application (Telerik MVC HTML5 Report Viewer)
Another solution includes the REST service for report generation and also the definition of reports using the Standalone designer.
In the first application, this is my link to myModule in _Layout.cshtml
@Html.ActionLink(
"Account List"
,
"AccountList"
,
"Home"
,
null
,
new
{ @
class
=
"sidebar-link"
, id =
"AccountListSide"
})
this is the call of my action method in HomeController.cs:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.Mvc;
namespace
FirstApp.Controllers
{
public
class
HomeController : Controller
{
public
ActionResult Index()
{
return
View();
}
public
ActionResult AccountList()
{
return
View();
}
}
}
this is my report Viewer: Home/AccountList.cshtml
@
using
Telerik.Reporting
@
using
Telerik.ReportViewer.Mvc
@{
Layout =
null
;
}
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title>Telerik MVC HTML5 Report Viewer</title>
<meta http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1"
/>
<script src=
"~/Scripts/jquery-3.5.1.min.js"
></script>
<link href=
"~/Content/kendo/2020.3.915/kendo.common.min.css"
rel=
"stylesheet"
/>
<link href=
"~/Content/kendo/2020.3.915/kendo.blueopal.min.css"
rel=
"stylesheet"
/>
<style>
#reportViewer1 {
position: relative;
width: 1300px;
height: 900px;
font-family: Verdana, Arial;
}
</style>
<!--If Kendo
is
used it should be added before the report viewer.-->
<script src=
"@Url.Content("
http:
//localhost:59374/api/reports/resources/js/telerikReportViewer-15.0.21.120.min.js/")"></script>
</head>
<body>
@(Html.TelerikReporting().ReportViewer()
.Id(
"reportViewer1"
)
.ServiceUrl(Url.Content(
"http://localhost:59374/api/reports"
))
.ReportSource(
new
UriReportSource() { Uri =
"ListAccountReport.trdp"
})
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(
false
)
.PrintMode(PrintMode.AutoSelect)
.EnableAccessibility(
false
)
)
</body>
</html>
In my second asp.net mvc application, i created the REST Service ReportController.cs
namespace
SecondApp.Controllers
{
using
System.IO;
using
System.Web;
using
Telerik.Reporting.Cache.File;
using
Telerik.Reporting.Services;
using
Telerik.Reporting.Services.WebApi;
//The class name determines the service URL.
//ReportsController class name defines /api/reports/ service URL.
public
class
ReportsController : ReportsControllerBase
{
static
ReportServiceConfiguration configurationInstance;
static
ReportsController()
{
//This is the folder that contains the report definitions
//In this case this is the Reports folder
var appPath = HttpContext.Current.Server.MapPath(
"~/"
);
var reportsPath = Path.Combine(appPath,
"Reports"
);
//Add resolver for trdx/trdp report definitions,
//then add resolver for class report definitions as fallback resolver;
//finally create the resolver and use it in the ReportServiceConfiguration instance.
var resolver =
new
UriReportSourceResolver(reportsPath)
.AddFallbackResolver(
new
TypeReportSourceResolver());
//Setup the ReportServiceConfiguration
configurationInstance =
new
ReportServiceConfiguration
{
HostAppId =
"Html5App"
,
Storage =
new
FileStorage(),
ReportSourceResolver = resolver,
// ReportSharingTimeout = 0,
// ClientSessionTimeout = 15,
};
}
public
ReportsController()
{
//Initialize the service configuration
this
.ReportServiceConfiguration = configurationInstance;
}
}
}
and under the second solution the Reports directory contains the definition of my report "ListAccountReport.trdp"
Another detail is activate CORS to access the service REST, I add in the 2nd app this snippet of code in web config:
<httpProtocol>
<customHeaders>
<add name=
"Access-Control-Allow-Origin"
value=
"*"
/>
<add name=
"Access-Control-Allow-Headers"
value=
"Content-Type"
/>
<add name=
"Access-Control-Allow-Methods"
value=
"GET, POST, PUT, DELETE, OPTIONS"
/>
<add name=
"Access-Control-Allow-Credentials"
value=
"true"
/>
</customHeaders>
</httpProtocol>
using only one solution, all works fine but separating the two parts in different solutions it throws me this error:
Unable to get report parameters.
Access to XMLHttpRequest at 'http://localhost:59374/api/reports/clients/6d5ac5243ca/parameters' from origin 'http://localhost:57654' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
jquery-3.5.1.min.js:2 POST http://localhost:59374/api/reports/clients/6d5ac5243ca/parameters net::ERR_FAILED
Thanks for replying
I have a large program with more than 20 reports which has been based on legacy Asp.net Web Forms Viewer. Given the legacy state of that control I decided to try to tackle the HTML5 viewer.
I have taken an existing project, forked it. Added a HTML5 viewer template based solution. That created a report controller which I had to customize. I chose to implement a custom resolver and it seems to be working well. In my development environment it works flawlessly. When deployed to my production server nothing I do gets it working. That server is as follows:
IIS 10 on Windows 2016 Server.
The error I keep getting is shown below. Symptomatically it seems that the routing, again in production only, is not happening. I have, to the best of my ability, implemented "CORS" although I am not sure I actually require it. The URL shown below is correct. I have tried using /Text/FInance/City-Import/api/reports/formats as suggested to no avail. Again, no routing seems to be happening.
I have tried using Fiddler and Chrome tools to no avail. They provide no clues other than it is not working.
Can anyone aid my troubles with a pointer towards what to look for? Given my successes on development IIS servers (older vintages), I suspect it might be something I have overlooked. Hopefully someone has something for me to look it at.
(Error message I am fighting)
Cannot access the Reporting REST service. (serviceUrl = '/Test/Finance/City-Import/api/reports/'). Make sure the service address is correct and enable CORS if needed. (https://enable-cors.org)
Hello,
I need to create a report with 3 pages and each page has to have different watermarks.
How can I achieve this?
I create 3 watermarks with following properties:
1. PrintOnFirstPage - true, PrintOnLastPage - false
2. PrintOnFirstPage - false, PrintOnLastPage - false
3. PrintOnFirstPage - false, PrintOnLastPage - true
But the result is:
On page 1 there is watermark 1.
On page 3 there is watermark 3.
But on page 2 there are watermarks 1 and 2 which are one over the other.
How can i fix this?
Thank you in advance!
Best regards,
Miroslav Vasilev
Hello,
Telerik report is using in our product/application and it was working fine.
But from last few week we got incident from our customer that print button from reportviewer is not working.
Our developer are trying to find put this issue and found this issue is getting from Reportviewer control. Attached screenshot of reportviewer.
We are not getting any error message, onclick on print button nothing happen. Can you please suggest us how we can resolve this issue, as all our customers are raising same issue.
Thanks & Regards,
Shekhar Das
I create report base on Telerik Reporting Q3 2015 SP1
my report contain 4 group headers
each data row return on report like detailsection|group1|group2|group3|group4
report use data return from database only fields that use format number digit or date format in expressions and no calculated field in report
report also use PageCount and PageNumber and 1 logo picture on PageHeaderSection
because this report have to be approved in the same document and data return from database is about 60,000 ~ 100,000 records, number of page about 3500-4000 pages
when I export as pdf it show message system out of memory exception in server side that report deploy in web MVC there is 2gb memory available.
my question is if export large data perform, how to calculate memory usage and plan to extend memory size on the server, or is there any way that improve my report when export file?
thank you.
I don't know how to solve my issue (to get rid of obsolete methods).
I have reportbook in which I dinamicaly inject diferent reports. Problem is that I'm setting datasource at runtime and not in report. This my code:
var resultMedalistReport =
new
Result_Medalists { DataSource = someDATA };
resultMedalistReport.ReportParameters[
"TournamentFullName"
].Value = _tournament.Title;
resultMedalistReport.ReportParameters[
"TournamentDate"
].Value = _tournament.DTTournamentStart.ToString(
"dd.MM.yyyy"
);
resultMedalistReport.ReportParameters[
"PageTitle"
].Value =
"Report.Medalists.PageTitle"
.Localize();
resultMedalistReport.ReportParameters[
"PageFooter"
].Value = cCommon.GetSettingString( groupName:
"Report"
, hashName:
"PageFooter"
);
reportBook.ReportSources.Add( resultMedalistReport );
//this line has implicit conversion that is obsolete.