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

[Solved] ComboBox without custom values

4 Answers 188 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Martin
Top achievements
Rank 1
Martin asked on 16 Apr 2012, 09:52 PM
Is it possible to configure the ComboBox so that no custom values can be entered?
Or can the DropDownList be configured to allow filtering (mode 'Contains')?

I'd like to have a selection control where the user can enter any part of the contained entries but optionally also click the down-arrow and select one of the values.

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Apr 2012, 03:11 PM
Hello Martin,

You can use the ComboBox widget to filter data. To prevent entering of a custom value you can wire the change event and check when the new value is not present in the data. Check this jsFiddle demo for more information.

Greetings,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Martin
Top achievements
Rank 1
answered on 17 Apr 2012, 03:37 PM
Hello Georgi,
your sample is for the Kendo widget - but my question was about the MVC controls.
Will this approach also work in my case? Is there anything that has to be change to make it work with MVC?

Thanks.
Martin
0
Georgi Krustev
Telerik team
answered on 17 Apr 2012, 05:04 PM
Hello Martin,

 
Yes, you need to use the same approach. Check this code snippet:

function onChange() {
    var combobox = $(this).data("tComboBox");
    if (combobox.value() && combobox.selectedIndex === -1) {
         //custom value;
    }
}

Greetings,
Georgi Krustev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Jo
Top achievements
Rank 1
answered on 09 May 2012, 09:31 PM
Hi Georgi,

That code snippet you provided only partially works.
One thing I noticed is when the user selects a valid value from the combobox, tabs out, returns to the combobox and enters an invalid value, the code inside the validation does not get kicked in.  The combobox still has the valid value's index (ie: <> -1).

Do you have other suggestions for validation?  I thought of using the DropDown, but the list contains very many records for the user to choose from that using this alternative does not seem feasible.

Thanks.
Tags
ComboBox
Asked by
Martin
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Martin
Top achievements
Rank 1
Jo
Top achievements
Rank 1
Share this question
or