Passing Report Parameters from Report Viewer

3 posts, 1 answers
  1. Shawn
    Shawn avatar
    7 posts
    Member since:
    Oct 2013

    Posted 14 Aug 2014 Link to this post

    I have a stand-alone HTML page based on the Report Viewer samples. This page calls the api/reports API. When my report is not parameterized, the Report Viewer works great and my report appears. I am now trying to add parameters to my report. 

    Here is my Report Viewer script that passes the parameter:
    $("#reportViewer1")
                .telerik_ReportViewer({
                    serviceUrl: "http://localhost:36563/api/reports/",
                    templateUrl: '/ReportViewer/templates/telerikReportViewerTemplate-8.1.14.804.html',
                    reportSource: {
                        report: "MembersTest.trdx",
                        parameters: {
                            LastName: 'McGuy'
                        }
                    }
                });

    Here is the parameter JSON being passed into '/api/reports/clients/085707-b6ce/parameters':
    [{"name":"LastName","type":"System.String","text":"Last Name","multivalue":false,"allowNull":false,"allowBlank":true,"isVisible":false,"autoRefresh":false,"hasChildParameters":false,"childParameters":null,"availableValues":null,"value":"McGuy","id":"LastName","label":"McGuy"}]

    So it appears to be passing the parameter. In fact, I added a text box that prints the LastName parameter, and when the report loads, it shows "McGuy", which is the value I am passing. But the report does not return any rows. Here is my report SQL:

    SELECT
    Last_Name, First_Name, Middle_Name, Birth_Date
    FROM
    Member
    WHERE
    (Last_Name = @LastName)

    When I go through the "Configure SQL Data Source" dialogues in the stand alone Report Builder, it returns records based on my parameter, when I preview.

    I am not sure what I am doing wrong. Any help would be great.









  2. Answer
    Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 18 Aug 2014 Link to this post

    Hello Shawn,

    Make sure that the report parameter is connected properly to the SQL Data Source parameter placeholder. For more information, please refer to the Using Parameters with the SqlDataSource component help article.

    Regards,
    Nasko
    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. DevCraft banner
  4. Shawn
    Shawn avatar
    7 posts
    Member since:
    Oct 2013

    Posted 18 Aug 2014 in reply to Nasko Link to this post

    Yep, looks like that was it. Somehow the DataSource got disconnected from the report. Thanks!
Back to Top