start auto list after 3 characters

4 posts, 0 answers
  1. Hitesh
    Hitesh avatar
    16 posts
    Member since:
    Jul 2012

    Posted 16 Jan 2013 Link to this post

    RadAutocompleteBox is working fine.

    but i have additional requirment that, auto search should start if user have entered 3 characters or more.

    i can write script, but does it have property which can be helpful.

  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 21 Jan 2013 Link to this post

    Hi Hitesh,

    In order to achieve this you will have to create a custom class deriving from the FilteringBehavior class, override the FindMatchingItems and return items only if the search string is more than 3 characters. After this you can initialize the new class in xaml and assign it to the RadAutoCompleteBox.
    <Window.Resources>
       <telerik:CustomFilteringBehavior x:Key="CustomFilteringBehavior" />
    </Window.Resources>
    ...
    <telerik:RadAutoCompleteBox ItemsSource="{Binding Items}" DisplayMemberPath="Name" FileringBehavior="{StaticResource CustomFilteringBehavior}" />

    All the best,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ralf
    Ralf avatar
    8 posts
    Member since:
    May 2012

    Posted 06 Feb 2013 Link to this post

    Hi Ivo,
    could you please post a example for the CustomFilteringBehavior

    Thank you - Ralf
  5. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 08 Feb 2013 Link to this post

    Hello Ralf,

    Here is an example of a custom FilteringBehavior class:
    public class CustomFilteringBehavior : FilteringBehavior
    {
        public override IEnumerable<object> FindMatchingItems(string searchText, System.Collections.IList items, IEnumerable<object> escapedItems, string textSearchPath, TextSearchMode textSearchMode)
        {
            if (searchText.Length > 3)
            {
                return base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode);
            }
     
            return Enumerable.Empty<object>();
        }
    }

    Kind regards,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top