Showing multi-value UI params in report

14 posts, 1 answers
  1. Martin P
    Martin P avatar
    30 posts
    Member since:
    Oct 2012

    Posted 02 Jul 2008 Link to this post

    Hi, I have a setup a multi-value UI parameter in a report and would like to show the comma seperated value list the user has selected in a textbox in the page header.

    just using "=Parameters.myParam" as the textbox expression renders as "System.Collections.ArrayList"

    Could you please advise me of the correct expression I should use?

    Many thanks
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 03 Jul 2008 Link to this post

    Hello Martin P,

    We're already using custom user function that does that for us in the ProductLineSales catalog online example:

    public static string FormatArray(ArrayList array)
            {
                StringBuilder sb = new StringBuilder();

                foreach (object o in array)
                {
                    if (sb.Length > 1)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(o.ToString());
                }

                return sb.ToString();
            }

    Hope this helps.

    Sincerely yours,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft banner
  4. Martin P
    Martin P avatar
    30 posts
    Member since:
    Oct 2012

    Posted 03 Jul 2008 Link to this post

    Hi, that's excellent, got that working ok now...one thing was I had to change the filter slightly as the array passed into the userdef Format function is the ValueMember.  Is there any way of passing the DisplayMember array of a report param into the userdef Format function?
  5. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 04 Jul 2008 Link to this post

    Hello Martin,

    Unfortunately passing the DisplayMember out of the box is currently not possible. Our developers are aware of this limitation and it would be addressed in a subsequent release.
    What you have done - change your parameter's ValueMember to be the meaningful column and changing the filter is the easiest and most straightforward way to proceed.
    If you however insist on working directly with the display member, there is a workaround. You can pass the current report item that invokes the user defined function as a parameter of the function. Then you can access the report instance using it.

    Take a look at the following code snippet:

    namespace ObjectDataBindungLib
    {
        using Telerik.Reporting;
        using System.Collections;
        using System.Data;

        /// <summary>
        /// Summary description for ReportParameterDataSource.
        /// </summary>
        public partial class ReportParameterDataSource : Report
        {
            public ReportParameterDataSource()
            {
                /// <summary>
                /// Required for telerik Reporting designer support
                /// </summary>
                InitializeComponent();

                // TODO: This line of code loads data into the 'categories.CategoriesTable' table. You can move, or remove it, as needed.
                try
                {
                    this.categoriesTableAdapter1.Fill(this.categories.CategoriesTable);
                }
                catch (System.Exception ex)
                {
                    // An error has occurred while filling the data set. Please check the exception for more information.
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }

                // TODO: This line of code loads data into the 'productCategory.ProductCategoryTable' table. You can move, or remove it, as needed.
                try
                {
                    this.productCategoryTableAdapter1.Fill(this.productCategory.ProductCategoryTable);
                }
                catch (System.Exception ex)
                {
                    // An error has occurred while filling the data set. Please check the exception for more information.
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }

            public static object GetLabels(object parameter, object reportItem)
            {
    //Access the report instance this way:
                Telerik.Reporting.Processing.Report processingReport = (reportItem as Telerik.Reporting.Processing.ReportItemBase).Report;
                Telerik.Reporting.Report report = processingReport.ItemDefinition as Telerik.Reporting.Report;

    //Access the dataset in one of these two ways:
                //ProductCategory dataset = report.ReportParameters["ProductCategoryID"].UI.AvailableValues.DataSource as ProductCategory;
                ProductCategory dataset = ((ReportParameterDataSource)report).productCategory;

                if (null != parameter)
                {
                    ICollection collection = parameter as ICollection;
                    if (null != collection)
                    {
                        string[] labels = new string[collection.Count];
                        int index = 0;
                        foreach (object value in collection)
                        {
                            DataRow row = dataset.ProductCategoryTable.Rows.Find(value);
                            labels[index] = (row as ProductCategory.ProductCategoryTableRow).Name;
                            index++;
                        }
                        return string.Join(", ", labels);
                    }
                }
                return null;
            }
        }
    }

    use the function like this:
    =GetLabels(Parameters.ProductCategoryID, ReportItem)

    But there is more advanced way to have the datasource shared for the parameter and for the user defined function, and you should consider using this approach: Separate the db access logic in a new class and call it's methods that return the data you need. This way you will have your data wherever you need it.


    Regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Bob
    Bob avatar
    21 posts
    Member since:
    Mar 2008

    Posted 24 Apr 2009 Link to this post

    Steve,

    This shows the value and you mention it is something your development team is looking into.  Do you have a method yet for the multi-text values?

    Bob
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 27 Apr 2009 Link to this post

    Hello Bob,

    Unfortunately the answer is no - we have not been able to work on the report parameters changes yet. However I've raised the priority of this task in our bug tracking system and we would do our best to implement it for one of the subsequent releases of the product.

    Regards,
    Steve
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Bryan Doan
    Bryan Doan avatar
    14 posts
    Member since:
    May 2010

    Posted 06 Sep 2010 Link to this post

    Hello,

    How do you pass multi value paramas to sql datasource?  I am trying to pass multi-value params but receive error  as below.  Would you please advise on how to do this or do you have an example/sample for multi-value params report somewhere that I can download?  Thanks!

    Failed to convert parameter value from a Object[] to a String.
    ------------- InnerException -------------
    Object must implement IConvertible.
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 06 Sep 2010 Link to this post

    Hello Bryan,

    The DataSource Components don't work out of the box with a MultiValue Report Parameter since the current implementation is based on ADO.NET and does not allow you to pass a collection of values (set, array). Thus, the SqlDataSourceParameter accepts only single values corresponding to the SqlDataSourceParameter.DbType property. Although this is a known limitation of ADO.NET and not a problem of our product, we're currently working on possible solution for it and it would be part of the upcoming Q2 SP1.

    Best wishes,
    Steve
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  10. Rakesh
    Rakesh avatar
    3 posts
    Member since:
    Sep 2010

    Posted 29 Oct 2010 Link to this post

    Its showing me an error as the expression contains undefined function call Formatarray
  11. jura
    jura avatar
    7 posts
    Member since:
    Feb 2007

    Posted 15 Nov 2010 Link to this post

    When I change function to this version, is works:
    public static string FormatArray(object array)
    {
    StringBuilder sb = new StringBuilder();
    foreach (object o in (array as Array) )
    {

    if (sb.Length > 1)
    {
    sb.Append(
    ", ");}
    sb.Append(o.ToString());
    }
    return sb.ToString();

     

    }

     

     

     

     

  12. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 16 Nov 2010 Link to this post

    Hi guys,

    Support for out of the box mapping database parameter to multivalue report parameter was implemented in the Q2 SP1 release.

    All the best,
    Steve
    the Telerik team
    See What's New in Telerik Reporting in Q3 2010 on Wednesday, November 17, 11am Eastern Time: Register here>>
  13. stan naspinski
    stan naspinski avatar
    1 posts
    Member since:
    Oct 2009

    Posted 24 Oct 2012 Link to this post

    Steve, you can replace this whole chunk of code:
    public static string FormatArray(ArrayList array)
    {
    StringBuilder sb = new StringBuilder();
     
    foreach (object o in array)
    {
    if (sb.Length > 1)
      {
      sb.Append(", ");
    }
      sb.Append(o.ToString());
    }
      return sb.ToString();
    }

    With just this:
    string.Join(", ", array.ToArray());

  14. Jolanta
    Jolanta avatar
    19 posts
    Member since:
    Oct 2014

    Posted 13 May 2015 in reply to stan naspinski Link to this post

    Hi, I want to find a solution:

    I have created a report, using data from several dataSources. One of the dataSource needs parameter to be chosen. It works fine.

    But now, I should be able to use multiselection of thit parameter. For each selected item, the whole report should be generated, then page-break and again for the next selected parameters a new one aso, each after another. So, finally, I would get a long report, which I can print at once, for mutliselected parameter.

    I though to create a table, in each row I would like to put a report for one of multiselected parameters.

    First my trouble is, that I can't retrive the single values of the selected parameter - I get only an object, using expression: Parameters.MyParameters.Value.

    Do you have any idea for my problem?

    Jola

  15. Stef
    Admin
    Stef avatar
    3053 posts

    Posted 15 May 2015 Link to this post

    Hi Jola,

    Multivalued report parameters' values are evaluated as arrays of objects. Thus if you want to see all values in the report, you can use the Join text function as follows: =Join(',',Parameters.MyMultivalueParameter.Value)

    If you need to pass such parameter to a SQL stored procedure, check my post in How pass multivalues param values to report MVC or HTML5?

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