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

Help Achieve Filtering as described

3 Answers 46 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 13 Jan 2010, 05:48 PM
We are trying to add a filtered RadComboBox control that behaves as follows:
-  When you start typing, filter the list with the Contains filter
-  If you leave the control (blur), and your current text doesn't match an existing item in the list, revert to the item that was selected when the page was loaded (the current value before the user started typing the filter key)

Our current attempt is close, but doesn't quite get there.  On blur, the combobox retains the value of whatever the user typed in, even though AllowCustomText is false.  If we set MarkFirstMatch to true, we prevent the user from leaving any text in the dropdown that doesn't match an existing item, however we would prefer to clear it out to its original value if an item wasn't selected directly:

<telerik:RadComboBox ID="_sicCode" runat="server" AllowCustomText="false" MarkFirstMatch="false" EmptyMessage="-- Select --" Filter="Contains" MaxHeight="150" /> 

Is there any way to achieve this behavior without extending the control?

3 Answers, 1 is accepted

Sort by
0
Jose
Top achievements
Rank 2
answered on 13 Jan 2010, 08:01 PM
Hi Keith.

If you use the client side event OnClientBlur then you can control what to put on the control once the user leaves it. You can use a hidden field to store the default value, and when the user selects an item of the filtered list, using the OnClientSelectedIndexChanged event you can modify the hidden field value so store the new selection so you always have a way to go back to the previous selection.

Hope this helps.

Jose Guay
0
Keith
Top achievements
Rank 1
answered on 13 Jan 2010, 10:21 PM
Thank you Jose.

This makes sense, and was what I was thinking of doing if I chose to extend the control (or create a user control).  I was hoping there was something we could do out of the box, and avoid reinventing the wheel if it was in fact already supported without doing what you mention.  Anyone from Telerik have some input on this?
0
Veselin Vasilev
Telerik team
answered on 18 Jan 2010, 10:46 AM
Hi Keith,

It is not supported out of the box because there are scenarios where a different behavior is expected.
That is why we provide a rich client side API in terms of methods and events so you can fine tune the behavior per your requirements.


Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Keith
Top achievements
Rank 1
Answers by
Jose
Top achievements
Rank 2
Keith
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or