I have a report/Invoice that was made using the Report Designer, so it's in trdp format. It is server up via a MVC vb.net RESTful reporting service. Despite countless setbacks due to the Telerik Report dynamic limitations, I actually have it working, but there it one final nail that needs to be pounded into the coffin...the Invoice Logo. It, much like every things else in our system, is not static. It needs to be set, to correspond to what company happens to be running the Invoice with that particular request.
The million dollar question, how does one dynamically set a picturebox in a trdp report via a call to a RESTful reporting service?
I have a sinking feeling this is going to involve the ReportPackager. The Reports Controller is very simple:
Namespace Controllers
<
RoutePrefix
("api/Reports")>
Public Class ReportsController
Inherits ReportsControllerBase
Protected Overrides Function CreateReportResolver() As IReportResolver
Dim reportsPath = HttpContext.Current.Server.MapPath("~/Reports")
Return New ReportFileResolver(reportsPath).AddFallbackResolver(New ReportTypeResolver())
End Function
Protected Overrides Function CreateCache() As ICache
Return Telerik.Reporting.Services.Engine.CacheFactory.CreateFileCache()
End Function
End Class
End Namespace
10 Answers, 1 is accepted
My suggestion is to use user function to map the images on the server and set the PictureBox.Value property. For example:
= ResolveUrl(Fields.LogoImage)
where ResolveUrl is a custom user function which you will have to create. The parameter of the function will be the actual image path (e.g. "~/images/xyzImage.jpg").
Please note that when the user function is implemented outside of report's class, it should be invoked from an expression by its fully qualified name, including the full namespace and the name of the type they belong to, and specifying the necessary parameters in the braces. For example:
= Telerik.Reporting.Report.Report1.ResolveUrl(Fields.LogoImage)
Best Regards,
Silviya
Progress Telerik
In the page that the user function anchor links to it states:
When any public static (Public Shared in VB.NET) method is part of the current report class. In this case they can be invoked from an expression by their name, specifying the necessary parameters in the braces:
Yet it never really points you to or tells you where the current report class exists? I have enough external references. If I have to create another project with another dll that I have to remember to update...my heads going to explode.
Well I figured this out on my own too. Since I already had a data controler serving up the data for the reports, I just added a custom function to figure out the location of the image file and return it via json. I call the api function in my javascript and send it to the report as a parameter. Ugly and didn't have to be that way, but it works. Even Excel has a way to add functions to worksheets.
There are so many small tweaks you guy could make to the reports to make them more programmer friendly. Instead, a report that should have taken me a couple of days, has taken me a few weeks to complete. Once I was down the rabit hole it was too late to climb out, but I will think twice about opening another hole should the need arise.
We are glad that you've already figured it out.
Please let me explain further about the usage of the custom function. The current report class means in the Report's code-behind, for example:
// this is my report's code behind
public
partial
class
UserFuncReport : Telerik.Reporting.Report
{
public
UserFuncReport()
{
InitializeComponent();
}
[Function(IsVisible =
false
)]
public
static
string
TestFunction(
string
text)
{
return
text;
}
}
= TestFunction(
"Some text here!"
)
However, if the function is created outside of the report's class (in a loaded assembly), it must be a static method that is accessible for the report class. In this case, it can be invoked by its fully qualified name.
Best Regards,
Silviya
Progress Telerik
In case of adding your own User Function in reports created with the Standalone Report Designer and then use it at design-time, you should note one thing.
Basically, there is no difference when using custom user functions in Type (.CS) and Declarative (.TRDP) reports.
To be accessible in Standalone Designer for design purposes, the corresponding assembly of the function should be registered in the designer's config file, as explained in the Extending Report Designer article. The custom functions will appear under Functions->Misc - check this screenshot for clarity.
Best Regards,
Silviya
Progress Telerik
No I get it. I managed to get the functions of an external assembly to work, but it was a huge pain in the arse.
- Gives me another project I have to remember to maintain
- whenever there are changes to functions I have to remember to recompile it and then move the published files to the report designer exe location and the report server bin file.
- let us not forget that the config file needs to be setup correctly, and not only the report servers config file but the report desogner config file.
It's a lot of hoops to jump thru. On top of that it's not exactly a clear cut process. I've been programming for over 25 years and it took me a solid week of research to find and put the pieces of the puzzle together when this whole process could be avoided if there was a way to add a user function to the report in the report designer. Quick, simple and easy is what you should strive to give your customers. Not some convoluted bandaid backdoor method, and that is exactly what this feels like.
That's my $.02 anyway. Trust me, I get that I sound like whiney little entitled asshat, but I've never been one to not speak my mind.
Sorry for the rant
Steve
We noticed the new feature request on our feedback portal: Ability to add user functions to reports instead of needing to use external assemblies.
Thank you for your input. We already approved it and would be implemented in future versions of our product. Unfortunately, I cannot name the exact date when the task will be in development. All tasks are sorted based on multiple criteria such as demand, severity, available and required resources etc.
Best Regards,
Silviya
Progress Telerik