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

Autocomplete > no results > event?

3 Answers 57 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Drammy
Top achievements
Rank 1
Drammy asked on 21 Dec 2010, 07:03 PM
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

3 Answers, 1 is accepted

Sort by
0
Michael Lilly
Top achievements
Rank 1
answered on 22 Dec 2010, 10:24 PM
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!
0
George
Telerik team
answered on 28 Dec 2010, 10:19 AM
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
0
Michael Lilly
Top achievements
Rank 1
answered on 03 Jan 2011, 10:21 PM
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.

Tags
ComboBox
Asked by
Drammy
Top achievements
Rank 1
Answers by
Michael Lilly
Top achievements
Rank 1
George
Telerik team
Share this question
or