Change the order of Suggestions

2 posts, 0 answers
  1. Simon
    Simon avatar
    1 posts
    Member since:
    Feb 2015

    Posted 11 May 2015 Link to this post

    Hi,

    I'm trying to change the order of the suggestions in an AutocompleteBox, since per default the suggestions are ordered alphabetically.

     

    I've got an ObservableCollection<City> (a collection of all cities in Germany with more than 1000 inhabitants), which is ordered by "Size" and used as the SuggestionsSource of the AutocompleteBox. The user can't see the Size, but only the Name. The AutocompleteBox changes the order, however. I would like to show the suggestions sorted by Size, not by Name. For example, if the user types "Ber", the topmost suggestion should be "Berlin".

    public class City
    {
        public City() { }
        public City(int size, string name) { Size = size; Name = name; }
     
        public int Size { get; set; }
        public string Name { get; set; }
    }

    How can I change the sorting behaviour of the SuggestionsSource?

     

    Thanks!
    Simon

     

  2. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    550 posts

    Posted 14 May 2015 Link to this post

    Hello Simon,

    Thank you for contacting us. Unfortunately, this scenario is not supported out of the box. I can suggest using an external control to display the suggested items. This way you will be able to use your sorting mechanism before you display the items. Unfortunately, this could decrease the performance of the control. I have attached a sample.

    Please, let us know if you have any other questions.

    Regards,
    Rosy Topchiyska
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top