This is a migrated thread and some comments may be shown as answers.

Reporting MVC4 + HTML5 - How to Pass Parameters

1 Answer 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Courtney
Top achievements
Rank 1
Courtney asked on 20 Oct 2013, 09:54 AM
Hi,

I've started using the new HTML5 reportviewer for MVC but unfortunately the samples and documentation seems to be pretty lacking.

How do I pass across a simple parameter to a report?  Either via a link - e.g.. a link to show an Invoice which contains the invoice id.

OR 

    Allowing user selection on a page and passing that to the report?

Stuff like this should be simple but there doesn't seem to be any documentation at all on it.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Oct 2013, 08:59 AM
Hi Courtney,

How to pass the parameter values initially is shown in the reportSource(rs) API reference. The report source object contains two fields: a report field which specifies the name of the report and a parameters field which contains the parameters as name-value pairs.

There are two ways to set the report parameters values based on user interaction. The first one is through the parameters area of the viewer. In this case you have to set the Visible property of the report parameter to true so that it can be visible there. The second way is through JavaScript code by using the ReportSource method of the viewer. Consider the following snippet:
$("#updateParam1Btn").click(function () {
    var viewer = $("#reportViewer1")
        .data("telerik_ReportViewer");
   
    var value = $("#param1").val();
   
    var rs = viewer.reportSource();
   
    rs.parameters.param1 = value;
   
    viewer.reportSource(rs);
});


Regards,
Peter
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Courtney
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or