findItemByText: StartsWith?

2 posts, 0 answers
  1. jc mag
    jc mag avatar
    106 posts
    Member since:
    Aug 2005

    Posted 21 Aug 2011 Link to this post

    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?
  2. Ivana
    Ivana avatar
    657 posts

    Posted 23 Aug 2011 Link to this post

    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,
    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 >>

Back to Top