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

Showing multi-value UI params in report

13 Answers 854 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Martin P
Top achievements
Rank 1
Martin P asked on 02 Jul 2008, 11:10 PM
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

13 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 03 Jul 2008, 01:18 PM
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
0
Martin P
Top achievements
Rank 1
answered on 03 Jul 2008, 06:10 PM
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?
0
Accepted
Steve
Telerik team
answered on 04 Jul 2008, 12:53 PM
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
0
Bob
Top achievements
Rank 1
answered on 24 Apr 2009, 07:08 PM
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
0
Steve
Telerik team
answered on 27 Apr 2009, 12:24 PM
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.
0
Bryan Doan
Top achievements
Rank 1
answered on 06 Sep 2010, 08:17 AM
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.
0
Steve
Telerik team
answered on 06 Sep 2010, 04:13 PM
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
0
Rakesh
Top achievements
Rank 1
answered on 29 Oct 2010, 03:39 PM
Its showing me an error as the expression contains undefined function call Formatarray
0
jura
Top achievements
Rank 1
answered on 15 Nov 2010, 01:27 PM
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();

 

}

 

 

 

 

0
Steve
Telerik team
answered on 16 Nov 2010, 07:08 PM
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>>
0
stan naspinski
Top achievements
Rank 1
answered on 24 Oct 2012, 09:36 PM
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());

0
Jolanta
Top achievements
Rank 1
Veteran
answered on 13 May 2015, 03:53 PM

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

0
Stef
Telerik team
answered on 15 May 2015, 12:37 PM
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
Tags
General Discussions
Asked by
Martin P
Top achievements
Rank 1
Answers by
Steve
Telerik team
Martin P
Top achievements
Rank 1
Bob
Top achievements
Rank 1
Bryan Doan
Top achievements
Rank 1
Rakesh
Top achievements
Rank 1
jura
Top achievements
Rank 1
stan naspinski
Top achievements
Rank 1
Jolanta
Top achievements
Rank 1
Veteran
Stef
Telerik team
Share this question
or