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

Dynamic change of filter operators and parameters reading

1 Answer 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Paweł asked on 07 May 2014, 10:35 AM
Hi Telerik team,
I would like put filter with 2 parameters "quantity" and "operator" (like combo box). For example 100 and >, or 200 and <=.
I've tried to add parameter in report constructor:

1.ReportParameter item = new ReportParameter("Par1", ReportParameterType.String, ">");
2. ReportParameters.Add(item);
3. string[] myarray = new string[3] { ">", "<", "=" };
4. ReportParameters["Par1"].AvailableValues.DataSource = myarray;
5. ReportParameters["Par1"].AvailableValues.ValueMember = "=Fields.Item";
6. ReportParameters["Par1"].Visible = true;

and handle PropertyChanged Event
1.ReportParameters["Par1"].PropertyChanged += ProductList_PropertyChanged;

But when I change Par1 nothing happens.
Ok. I've handled ProductList_ItemDataBinding event, and tried to change operator:

01.void ProductList_ItemDataBinding(object sender, EventArgs e)
02.       {
03.           Console.WriteLine("Event: ItemDataBinding");
04.           Console.WriteLine("Par1: " + (string)ReportParameters["Par1"].Value);
05.           Console.WriteLine("Quantity:" + (string)ReportParameters["Liczba"].Value);
06.           switch ((string)ReportParameters["Par1"].Value)
08.          {
09.               case "<":
10.                   Filters[0].Operator = FilterOperator.LessThan;
11.                   break;
12.               case ">":
13.                   Filters[0].Operator = FilterOperator.GreaterThan;
14.                   break;
15.               case "=":
16.                   Filters[0].Operator = FilterOperator.Equal;
17.                   break;
18.               default:
19.                   break;
20.           }
21.       }

but when I try read parameter 
1.Console.WriteLine("Par1: " + (string)ReportParameters["Par1"].Value);

I always get what was set in constructor ">", quantity also is constant.

Probably something I don't understand but how can I read parameters, set in the report viewer? Is it even possible?
Any help is apprecitated.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 10 May 2014, 04:47 PM
Hello Paweł,

Events are not recommended for the operation you need to implement. At the time they fire the data processing has started, and modifying the report definition may lead to unexpected rendering later.

Instead of this, our recommendation is to create a method, in which the data retrieval can be controlled via parameters. The method can be wrapped by an ObjectDataSource component and its parameters to be mapped to report parameters. The setup steps are illustrated in the ObjectDataSource Wizard article.


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.

General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question