Autocomplete > no results > event?

4 posts, 0 answers
  1. Drammy
    Drammy avatar
    38 posts
    Member since:
    Feb 2008

    Posted 21 Dec 2010 Link to this post

    Hi all,

    I'd like to capture the situation where zero records are returned by the RadComboBox AutoComplete functionality (preferrably using MVVM).

    ie.  A user types into a RadComboBox and the available records are filtered, eventually to the point where there are no records.  At this point I need to prompt the user to add a new record to the List the ComboBox is bound to.  I also want to capture the text entered as this will form one of the values on the object being searched for.

    Any ideas?


    Cheers,
    Drammy
  2. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 22 Dec 2010 Link to this post

    I am also looking for an example of this functionality.  I need to capture when a user enters a value that doesn't exist in the list and do some special handling.

    Thanks!
  3. DevCraft banner
  4. George
    Admin
    George avatar
    1332 posts

    Posted 28 Dec 2010 Link to this post

    Hello,

    Unfortunately, the RadComboBox is not designed to support such scenario. I would suggest you to:

    1. handle the LostFocus event of the RadComboBox. In the handler, you could check whether the input value is in the collection and if it is not, you could add the new record.
    2. find the TextBox, placed in the RadComboBox (in edit mode) using ChildrenOfType<TextBox>. You could bind the Text property of the TextBox control and check whether the input value is in the collection and if it is not, you could add the new record.

    I hope this helps.


    Greetings,
    George
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 03 Jan 2011 Link to this post

    I initially implemented the lost focus event, and that was a decent solution, but wasn't a great solution for me.

    After your reply, I started down another path that seems to be a perfect fit.  I implemented the SelectionChanged event, and when the selected item is null (ie not an item in the list) I run the necessary code for a new item.  It does trigger on the first character typed that doesn't appear in the list (For example, Mike is in the list, but Michael isn't, so when Mic is typed, the event triggers with a null selected item) so you have to account for that since the user may not be done typing.  But it is perfect for me.

    I thought Drammy or someone else might find that info useful.

Back to Top