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

findItemByText: StartsWith?

1 Answer 66 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
jc mag
Top achievements
Rank 1
jc mag asked on 21 Aug 2011, 02:52 PM
The current findItemByText client-side function looks for items with exact text match. Is it possible to use it (or another function) more like a "StartsWith" function?

1 Answer, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 23 Aug 2011, 07:40 AM
Hello Jc,

In order to achieve the desired functionality you should develop a custom method implementing it, there is no build in function available.

You can use JavaScript method  indexOf   to check if a text starts with a given string.
Using JavaScript you can find the RadListBox control by its ID, after that get the items of the RadListBox  and make a loop over them to check  if the text of an item contains the string given as an argument.

string.indexOf(searchstring, start) - returns -1 if no match is found.
*string - the string you search in (in our case item's text).
*searchstring - the string you are searching for.
*start - the position from which you want to start the searching (ex. if start=0 the searching starts from the first letter of the string).

Best wishes,
Ivana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
ListBox
Asked by
jc mag
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Share this question
or