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

External Report Viewer Parameters

2 Answers 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
G-Man
Top achievements
Rank 1
G-Man asked on 07 Oct 2013, 03:43 AM
Hi,

What I require is to be able to pass parameters to a report that don't exist as part of the actual report viewer control.  In other words, I need to be able to ask the user for information in a form and then post that information to the report viewer further down the page.

I've managed to get this working by using the following javascript in the click event of my form button:

$('#btnUpdateReport').click(function () {
        // add the parameters to the controller parameters
        var pId = $('#txtPortfolioId').val();
        var viewer = $reportViewer.data('telerik_ReportViewer');
        viewer.reportSource($.extend({}, viewer.reportSource(), { parameters: { 'portfolioId': pId } }));
});

I can see that the POST actions in Firebug are as follows when the number "1" is entered into the text box outside the viewer:
/api/reports/clients/142151-0f94/ReportingPrototype.Reports.InvestmentStrategy, ReportingPrototype/parameters?{"portfolioId":"1"}=
/api/reports/clients/142151-0f94/instances?{"report":"ReportingPrototype.Reports.InvestmentStrategy, ReportingPrototype","parameterValues":{"portfolioId":1}}=

The problem is, the query that's generated against the database to return results passes in a 'NULL' value to set against the parameter "@portfolioId".

What am I doing wrong?

Cheers.


2 Answers, 1 is accepted

Sort by
0
Accepted
Chavdar
Telerik team
answered on 09 Oct 2013, 01:22 PM
Hi,

The code snippet that you have provided is correct and this is the right way of passing report parameters from the client.

A possible reason for the problem is that you have not linked the report parameter to a parameter of the SqlDataSource component. Additional information you can find in the Using Parameters with the SqlDataSource component  help article and more specifically in the Binding SQL Query Parameters to Report Parameters section. You can setup the data source parameters at design time as well.

Additionally you can check whether the report is working correctly in any of the the other viewers.

Regards,
Chavdar
Telerik

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

0
G-Man
Top achievements
Rank 1
answered on 09 Oct 2013, 10:41 PM
That did the trick!  I was missing a setting in the report designer with the "Value" property of the portfolioId parameter.  I needed to set it to:

=Parameters.portfolioId.Value

Thanks for your help.
Tags
General Discussions
Asked by
G-Man
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
G-Man
Top achievements
Rank 1
Share this question
or