How does one dynamically set a picturebox in a trdp report via a call to a RESTful reporting service?

11 posts, 0 answers
  1. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 05 Mar Link to this post

    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
  2. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 06 Mar Link to this post

    So i already have this RESTful Reporting Service serving up the report.  Maybe this is doable using a custom function?  What would I do just add class to the Report Service and call it from the Report?  
  3. Silviya
    Admin
    Silviya avatar
    379 posts

    Posted 08 Mar Link to this post

    Hello SSirica,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 12 Mar in reply to Silviya Link to this post

    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.  

  5. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 13 Mar Link to this post

    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.  

  6. Silviya
    Admin
    Silviya avatar
    379 posts

    Posted 14 Mar Link to this post

    Hello SSirica,

    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;
        }
    }
    In the report, the expression for the custom User Function will look like:
    = TestFunction("Some text here!")

    However, if the function is created outside of the report's class (in a loaded assembly), it must be static method that is accessible for the report class. In this case, it can be invoked by its fully qualified name. 

    Still, I want to thank you for your product feedback. We are always trying to improve our products, so it will be really helpful if you point us if there are functionalities that are missing out-of-the-box or could be further improved, so we can do our best to enhance them in future. You might open new Feature Requests/Bug Reports on our Feedback and Ideas Portal: For Telerik Reporting it could be found here, and for Telerik Report Server - here.

    Best Regards,
    Silviya
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 14 Mar in reply to Silviya Link to this post

    That's fine, but a trdp report doesn't have any code behind.  If it does, please point me in the right direction to find it.  If not, then that's my point all along...there should be.  
  8. Silviya
    Admin
    Silviya avatar
    379 posts

    Posted 15 Mar Link to this post

    Hi SSirica,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 15 Mar in reply to Silviya Link to this post

    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. 

    1. Gives me another project I have to remember to maintain
    2. 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.  
    3. 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

  10. Silviya
    Admin
    Silviya avatar
    379 posts

    Posted 18 Mar Link to this post

    Hello SSirica,

    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.

    Alternatively, you can follow the feature request to check if the status is changed to 'In Development' and also our release history page for release notes.

    Best Regards,
    Silviya
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  11. SSirica
    SSirica avatar
    83 posts
    Member since:
    Jan 2007

    Posted 18 Mar in reply to Silviya Link to this post

    That's awersome!  Thank you!
Back to Top