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

Paramenter/Filter case sensative?

3 Answers 258 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 24 Sep 2008, 02:24 AM
How to make Telerik report Parameter/Filter searching none case sensative?
If I set field TOPIC as Paramter as well as Filter, I try to find "school", get search result, I try to search 'School' returns nothing.

The "Like" filter operatior doesn't seem to work also. If I serach "schoo" I get nothing, unless I try "school".

Did I miss anything?  My dataset case sensative is set false as defaut setting.

3 Answers, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 24 Sep 2008, 10:41 PM
Hello Suzanne,

The string comparison is case sensitive by design. The reason is that if one needs to make it insensitive, it can be easily achieved by applying ToLower or ToUpper on both the left and right sides of the comparison.
But if the comparison was case insensitive and you needed sensitivity, your hands would be tied.

So in your case you can write an user defined function, for example:

        public static string StringToUpper(object value)
        {
            if (null == value || System.DBNull.Value == value)
            {
                return string.Empty;
            }
            return value.ToString().ToUpper();
        }


Then in the filter use:
        =StringToUpper(Fields.MyField)   =   =StringToUpper(Parameters.MyParameter)

Also as an alternative of the user defined function you can use the string.ToUpper method directly in the expression but you need to ensure a not null value. Something like:
        =CStr(IsNull(Fields.MyField, "")).ToUpper()   =   =CStr(IsNull(Parameters.MyParameter, "")).ToUpper()

As for the Like operator to work, in the right side of the operator you need to use some wild card symbol(s), just like in SQL, something like:
        =StringToUpper(Fields.MyField)   Like   ="%" + StringToUpper(Parameters.MyParameter) + "%"

Try it out and write us if you need further assistance.

More info on User defined functions, operators, etc. you can find in the help topic Using Expressions.

Greetings,
Milen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matt
Top achievements
Rank 1
answered on 29 Sep 2014, 08:25 PM
I believe the issue that Matt is referring to is the fact that using the reporting API there isn't an option to ignore case.  String comparisons work well if you are directly building the filter critieria, but this doesn't apply to situations where you are using the API directly such as:

report.Filters.Add(myfiltercriteria)

Unless there is some property that I have overlooked.  I am running into the same situation.  I would like to turn off case-sensitivity for my report filter while still using the API.

Thanks,

Matt R.
0
Stef
Telerik team
answered on 30 Sep 2014, 02:24 PM
Hi Matt,

The suggested approach is applicable also if you are using directly the API to add a fileter. For example check the code snippets in the How to: Add filtering to Report article.

To add a filter you need to specify the expression, the operator and the value to evaluate in code. The expression and value parts can be set to an expression as custom function or string formatted in code.


In order to provide you more accurate suggestions, please elaborate on the scenario with code snippets and examples of specific values not working with the added filter.

Regards,
Stef
Telerik
 

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.

 
Tags
General Discussions
Asked by
Matt
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Matt
Top achievements
Rank 1
Stef
Telerik team
Share this question
or