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

Client-side findItemByText

3 Answers 243 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 2
Steve asked on 27 Feb 2009, 08:58 PM
I have a simple "State" dropdown where the text values of items are the abbreviations of States (e.g. "VA").  I allow the user to type in a custom value because I didn't want to put a "Select State" kind of option but want to use filtering.  Anyway, user types in "va" and the client-side "findItemByText" does not find the item for "VA".  Is there any way to get this method to NOT be case sensitive?

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 02 Mar 2009, 04:16 PM
Hello Steve,

By default Filtering is not case sensitive. The javascript method findItemByText is case sensitive.

You need to define your own client method to work as case insensitive. Here is the code:

function findItemByText2(theText) 
    var combo = $find("<%= RadComboBox1.ClientID %>"); 
    var items = combo.get_items(); 
    var itemsCount = items.get_count(); 
 
    for (var i = 0; i < itemsCount; i++) 
    { 
        var item = items.getItem(i); 
        if (item.get_text().toLowerCase() == theText.toLowerCase()
        { 
            return item; 
        } 
    } 
    return null

I hope this helps.

Greetings,
Veselin Vasilev
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
Steve
Top achievements
Rank 2
answered on 02 Mar 2009, 08:11 PM
Yep, I knew your solution was a possibility.  I was hoping not to have to manually traverse the item collection just to find a match.  Would be nice if there was a property in the future to instruct that method how to compare.  Seems pretty straightforward to me.  Thanks for the response.
0
Veselin Vasilev
Telerik team
answered on 03 Mar 2009, 09:34 AM
Hi Steve,

If we were to create the method - we would do it in a similar way.

Regards,
Veselin Vasilev
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.
Tags
ComboBox
Asked by
Steve
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Steve
Top achievements
Rank 2
Share this question
or