how to pass multivalue parameter from jQuery.fn.telerik_ReportViewer reportSource?

8 posts, 1 answers
  1. tiffany
    tiffany avatar
    24 posts
    Member since:
    Jan 2014

    Posted 09 Feb 2014 Link to this post

    I have a report with a multivalue parameter. It works fine in preview. But I tried to pass selections from my own multi-select combo box (selection is string type) from jQuery.fn.telerik_ReportViewer, it doesn't work, see below. What's the correct syntax ?

    $("#reportViewer1")
                      .telerik_ReportViewer({
                          serviceUrl: "api/Reports/",
                          templateUrl: 'ReportViewer/templates/telerikReportViewerTemplate.html',
                          reportSource: {
                              report: "ReportLibrary.test, ReportLibrary",
                              parameters: {                               
                                  para1: " 'test1', 'test2'"                     
                                   }
                          },
                          viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
                          scaleMode: telerikReportViewer.ScaleModes.FIT_PAGE_WIDTH,
                          scale: 1.0,
                          ready: function () {
                              //this.refreshReport();
                          }
                      })

















































  2. Answer
    Stef
    Admin
    Stef avatar
    3046 posts

    Posted 12 Feb 2014 Link to this post

    Hello,

    I believe you already discussed this issue with my colleague in your support thread on the same question. Here is a quote for anyone concerned:

    "Passing multiple values to a parameter is achieved through an object array. Consider the following sample:
    <script type="text/javascript">
        $(document).ready(function () {
            $("#reportViewer1")
                .telerik_ReportViewer({
                    serviceUrl: "api/reports/",
                    templateUrl: 'ReportViewer/templates/telerikReportViewerTemplate.html',
                    reportSource: {
                        report: "Telerik.Reporting.Examples.CSharp.ReportCatalog, CSharp.ReportLibrary",
                        parameters: { MultivalueParam: ["ER Prelim Report", "Minor ERD"] }
                    },
                    viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
                    scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
                    scale: 1.0,
                    ready: function () {
                        //this.refreshReport();
                    },
                });
        });
    </script>
    "


    Regards,
    Stef
    Telerik

    New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

  3. DevCraft banner
  4. Bryant
    Bryant avatar
    2 posts
    Member since:
    Jan 2014

    Posted 10 Mar 2014 Link to this post

    How do you add this using the Html extension helpers?

    @{
            var report = new UriReportSource() { Uri = "TransactionTotals.trdx" };
            report.Parameters.Add( "AccountNumber", baseController.CurrentAccount.AccountId );
            report.Parameters.Add( "StartDate", DateTime.Now.AddDays( -30 ) );
            report.Parameters.Add( "EndDate", DateTime.Now );
            report.Parameters.Add(); // multi value param?
        }
  5. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 13 Mar 2014 Link to this post

    Hello Bryant,

    You can still use an object array in the HTML extension helpers:
    report.Parameters.Add( "MultiValueParameter", new object[] { "Value1", "Value2" });

    Regards,
    Nasko
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
  6. Kyle
    Kyle avatar
    15 posts
    Member since:
    Mar 2016

    Posted 20 Jul Link to this post

    I'm getting an error:

    Failed to convert parameter value from a Object[] to a IEnumerable`1.
    ------------- InnerException -------------
    Object must implement IConvertible

    When I pass a multi value parameter as specified above. The parameter is supposed to be fed to a Sql data source as a Table type with one column of ints. Is this the wrong way to do this?

  7. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 21 Jul Link to this post

    Hi Kyle,

    If you are using a SQL stored procedure and you need to pass a multivalue treport parameter, the multi-value report parameter is evaluated as an array of objects that cannot be passed directly. Table-valued SQL parameters are not supported.

    An example and possible settings in the stored procedure are illustrated in the How to use MultiValue Report Parameter in a SQL query KB article.



    I hope this helps.

    Regards,
    Stef
    Telerik by Progress
    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
  8. Kyle
    Kyle avatar
    15 posts
    Member since:
    Mar 2016

    Posted 21 Jul in reply to Stef Link to this post

    I ended up just using an object data source and converting the parameters to the specified table type before executing the query and returning a DataTable. It's not awful doing it this way but I wish the report designer supported all of the necessary types including user-defined types. It would also be a huge help if we were allowed to specify object data source members without the DLL being accessible, as the report viewer often has trouble detecting the DLLs even when set up in the config.
  9. Stef
    Admin
    Stef avatar
    3046 posts

    Posted 25 Jul Link to this post

    Hello Kyle,

    Values that can be submitted to data retrieval methods are of the types supported by report parameters.Custom types are not supported, which includes user-defined types and Table-valued variables for SQL queries which are specific per .NET data provider, and SQL database respectively.

    Thus the used workaround is also recommended by us - create a custom data access layer that casts and creates arguments, and executes the required methods.


    About using custom data access layers in the Standalone Report Designer, the assembly can be loaded from the folder or sub folder of the Standalone Report Designer - Extending Report Designer. The same settings must be applied to applications displaying the produced reports - Previewing a report definition that uses an external assembly.

    Regards,
    Stef
    Telerik by Progress
    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
Back to Top
DevCraft banner