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

How to retrieve/modify Reporting Parameters in runtime?

3 Answers 786 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
MARIANO
Top achievements
Rank 1
MARIANO asked on 02 Jun 2017, 01:46 PM

Greetings!  

I need help with receiving parameters from a report. The following code allows me to alter the DataSource of such Report, however I still need to intercept and alter the parameters used on that report.

 

01.public Telerik.Reporting.ReportSource Resolve(string report)
02.    {
03.        ReportSource reportInstance;
04.         
05.        //retrieve an instance of the report
06.        var connectionString = "Data Source=OurServer;Initial Catalog=OurDataBase;User ID=xxxxxxxx;xxxxxxx;";
07.        ReportConnectionStringManager csm = new ReportConnectionStringManager(connectionString);
08. 
09.        var appPath = HttpContext.Current.Server.MapPath("~/");
10.        var reportsPath = Path.Combine(appPath, "Reports");
11.        var uri = Path.Combine(reportsPath, report);
12. 
13.        var sourceReportSource = new UriReportSource() { Uri = uri };
14. 
15.        reportInstance = csm.UpdateReportSource(sourceReportSource);
16. 
17.        return reportInstance;
18.    }

Is it possible to receive and modify parameters from the report call utilizing HttpContext.Current ?  Or is there a Telerik Class/Method that allows me to do so?

Thanks in advance! Best Regards. 

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 02 Jun 2017, 04:31 PM
Hello Mariano,

In this resolve method, you can set default values to each parameter in the report instance's ReportParameters collection. You can also set the values through the reportSource.Parameters collection.

If the client sends another values for report parameters, they will be applied over the reportSource.Parameters collection.
if you need to check what parameters are sent by the client and log them, you can override the CreateInstance method of the Reporting REST Service.


In order to provide you more accurate suggestions, please elaborate on the scenario, how report parameters are used and the reason to modify the user's selected parameters' values.

Regards,
Stef
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
0
MARIANO
Top achievements
Rank 1
answered on 02 Jun 2017, 05:23 PM

Hello Steff, thank you for the fast answer.

The scenario is that I am trying to access different datasources for different parameters not selected by the users. For example, I'm going to send an extra parameter like "1" or "2" to access database 1 or 2, so that's why I need a way to intercept a parameter. 

Here's a following code with my .JS function that is called when the user wishes to create a report. inside, I wish to get the value of "base" to correctly set the data source for the report. 

 

$("#reportViewer1").telerik_ReportViewer({
               serviceUrl: "http://localhost:248/api/reports",
               templateUrl: "/fakepath/telerikReportViewerTemplate-8.2.14.1222.html",
               scaleMode: "FIT_PAGE_WIDTH",
               reportSource: {
                   report: "MyReport.trdx",
                   parameters: {
                       Month: selectedMonth,
                       Year: selectedYear,
                       base: ourParameter
                   }
               },
           });

 

Best Regards, Mariano

0
Stef
Telerik team
answered on 05 Jun 2017, 04:44 PM
Hello Mariano,

The value of the base report parameter will be available at the client and in the processing report (events, expressions). If you need to check the value, you can use the HTML5 Viewer's events at the client or switch to custom UI allowing you to evaluate the selected values before sending them to the server.

Regards,
Stef
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
Tags
General Discussions
Asked by
MARIANO
Top achievements
Rank 1
Answers by
Stef
Telerik team
MARIANO
Top achievements
Rank 1
Share this question
or