ReportViewer (html) Parameters are not refreshing in the report.

7 posts, 0 answers
  1. Toby
    Toby avatar
    5 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2014 Link to this post

    The report I'm building is using a CustomReportResolver and has System, ReportName and Footer parameters that I am adding to the report at runtime.  Whenever the user selects new criteria for the report (handled separately) and then refreshes the ReportViewer in the MVC page (razor), I then rebuild the report from scratch - re-adding the parameters with respective values, along side my custom data object source.  The problem is with displaying the footer text parameter that contains a big long string describing the criteria that the user has selected.  However, even though I can see, using breakpoints, that the report being built contains the updated footer text, when the report refreshes (html5 / web/api) the footer parameter still contains the text from the first time it was built.  Why are the parameters being cached even though its a brand new Telerik.Report object? and how can I stop this so it will show the latest text that I've added?


  2. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 30 Sep 2014 Link to this post

    Hi Toby,

    Please double check if you have set the viewer's persistSession option to true. It causes the report to be preserved between requests.

    Also report parameters values must be set directly to the report's ReportParameters collection in the custom resolver, or sent from the viewer's reportSource.parameters option. In order parameters to be sent correctly, you must have a reference to Newtonsoft.Json.dll, which assembly should not be installed on the machine, but added through Nuget.


    I hope the above information is helpful.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Toby
    Toby avatar
    5 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2014 in reply to Stef Link to this post

    Thanks Stef for your response.  I have tried both true and false on the ReportViewer PersistSession option and neither have resolved the issue.  I believe it is because I am trying to cheat.  Let me explain.  In my custom data resolver, I build my DataObject with a number of fields.  I had ReportTitle and Footer in the data object to start with and had no problems with the values being correctly displayed in the report, however, I felt uncomfortable knowing the fact that my footer field would be repeated 10,000x times within the dataset, so thought by using Parameters I could pass static text just the once (without unnecessarily bloating my data object) for both the reportTitle and Footer.  So I changed my textbox from =Fields.ReportTitle to =Parameters.ReportTitle.Value - and this works on initial load up, however, after I update values via the website, ie. Change the footer text value, and when rebuilding the report it eventually still shows initial footer...   An observation I have made is when I view the Parameters while the report runs (and the panel to the right appears) - If I updated the value here, the report reflects the new values fine, but doing this via code does not seem to work which leads me to the question - is there any other way to pass data to the report on an adhoc basis?  ie. None repeated data such as Header Titles or footer/summary text that I do not want repeated in the datasource object?
  4. Toby
    Toby avatar
    5 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2014 in reply to Toby Link to this post

    Couple of screenshots - 1 is a watch on ReportObject.ReportParameters.Item[2] - showing the correct text that I'm expecting to see in the report.
    2 is the screen shot of the Footer textbox (defined as =Parameters.Footer.Value) - Not showing the text from screengrab 1 (notice Deliver locations are not updated to Granton, Website.
  5. Toby
    Toby avatar
    5 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2014 Link to this post

    The following screenshot taken from the BuildReport routine, above this code I place values from the viewModel that is passed into formatted strings, ie, system, footer, reportName.  The screenshot then shows how I am adding these parameters to the report.  Note that the report (in designer) does not have any parameters defined.
  6. Toby
    Toby avatar
    5 posts
    Member since:
    Jun 2014

    Posted 30 Sep 2014 Link to this post

    Oh I forgot to say - I do have a reference to Newtonsoft.Json.dll.
  7. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 03 Oct 2014 Link to this post

    Hello Toby,

    In the given example you are building the report at run-time in the custom resolver. It is not clear how you update the parameters values from the client and send a request to the viewer to the refresh its content.

    Please, debug the code to check if at the time you call the viewer's refreshReport method, the model's properties are updated correctly and the report is rebuild as expected in the custom resolver. Note the custom resolver's Resolve method is called 3 times and the model's properties must be preserved on each call.

    Test also to add the parameters to the report definition in the resolver, and pass the values from the client - How To: Pass values to report parameters.

    You can also record with Fiddler the requests and check them in the Inspectors - Request/Response - Raw tab.


    The attached demo project illustrates both approaches for assigning a report parameter's value, which work as expected.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top