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

Using wildcard in report Filters

3 Answers 408 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brenda
Top achievements
Rank 1
Brenda asked on 15 Jun 2008, 07:09 AM
Hi,
1 Ques. I am trying to create a report filter which should use a parameter value which is a variable along with a wildcard report.
I want to get the result for a SQL query like:
"Select users from Usertable where UserName LIKE %@Name%"

I am trying to get the "@Name" from the Parameter. Have enabled the UI for the parameter.

Here is the filter:

Filter:
("=Fields.[Name]", ((Telerik.Reporting.Data.FilterOperator)(Telerik.Reporting.Data.FilterOperator.Like)), "=Trim(Parameters.Name)")});
If have tried following in the value field :
=%Parameters.Name% : Gives Missing Operand for Mod operator.
=Parameters.Name: This works but does an exact match, I need a wildcard support.


2 Ques. Is there a way to enable filter only when the user selects/inputs any value for the parameters in the UI.
I want to display all the records by default. But when I set filters and get the parameter values from UI the report does not display any values by default.

Thank you for your help.

-Brenda.

3 Answers, 1 is accepted

Sort by
0
Milen
Telerik team
answered on 19 Jun 2008, 09:42 AM
Hi Brenda,

In the Value column of the Filter operator Like you need to provide a string literal. So if you need to provide a constant string, such that does not change for the different runs of the report you can use for example

%Bob%
.

In your case, where you need to provide different values for different runs of the report, you have to use an expression, that will be evaluated to different strings at runtime based on different values of the parameter.

So you need to use something like:

="%" + Parameters.Name + "%"

or

=Format("%{0}%", Parameters.Name)

About your second question:

In the UI settings of the report parameter change the AllowBlank property to true (I assume that your Name parameter is of string type). This way the users are allowed to leave the text box of the parameter blank, and in this case the Like Filter will be evaluated to true for each row of your datasource, so all records will be included in the report.

Write us if you need further assistance.

Kind regards,
Milen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
PatD
Top achievements
Rank 1
answered on 03 Sep 2009, 02:54 PM
Hi Milen,

I build my Parameters and Filters in the code behnid. This is working great.

But the Filter Operator Like works only if the user type the wildcard character (%) is the filter box.

I tried a couple of methods to include the % in the code behind but none is working:

myReport.Filters.Add("=Fields.PROD_DESC", Telerik.Reporting.Data.FilterOperator.Like, "%" & "=Parameters.ProdDesc" & "%")
or
myReport.Filters.Add("=Fields.PROD_DESC", Telerik.Reporting.Data.FilterOperator.Like, "=%Parameters.ProdDesc%")

Do you have a solution ?

Thank you for you help,

Patrick D.
Montreal, QC
0
Svetoslav
Telerik team
answered on 03 Sep 2009, 04:21 PM
Hello PatD,

The two filters have invalid value expressions. Please try this one instead:

='%' + Parameters.ProdDesc + '%'

The difference is that you have to concatenate the wildcards with the parameter in an expression so when the filter is evaluated the correct value will be used. For example if the value of the ProdDesc parameter is "Bike" after evaluation the filter will be executed with "%Bike%" value.

For additional information please see the following help topics:

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Brenda
Top achievements
Rank 1
Answers by
Milen
Telerik team
PatD
Top achievements
Rank 1
Svetoslav
Telerik team
Share this question
or