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

[Solved] Some problem with the combobox using the CascadeTo

1 Answer 131 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.
Julien
Top achievements
Rank 1
Julien asked on 21 May 2012, 01:42 PM
Hi,

I'm trying to use the CascadeTo element, but I'm having some troubles to use it:

I'm having two combo box:

@(Html.Telerik().ComboBoxFor(model => model.IdPublication)
                                            .Name("IdPublication")
                                            .BindTo(new SelectList(Model.AvailablePublications, "Id", "Name"))
                                            .HighlightFirstMatch(true)
                                            .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                                            .Placeholder(LocalizationResources.Views.Composer.BaseInfoForm.SelectPublicationPlaceHolder)
                                            .CascadeTo("IdFormat")
                                            .SelectedIndex(0)
                                            .Enable(true)
                                        )
 
@(Html.Telerik().ComboBoxFor(model => model.IdFormat)
                                            .Name("IdFormat")
                                            .HighlightFirstMatch(true)
                                            .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.Contains))
                                            .Placeholder(LocalizationResources.Views.Composer.BaseInfoForm.SelectFormatPlaceHolder)
                                            .SelectedIndex(0)
                                            .DataBinding(binding => binding.Ajax().Select("_GetFormats", "Home", new { area="Composer"}))
                                            .Enable(false)
                                        )

Here are my questions/problems:
  1. The second combo-box is loading when I'm selecting something in the first one, OK, but why does it calls also the _GetFormats methods when I'm typping something in the combo-box? I want to load only once the list of format, and then use it.
  2. When I select something in the first combo-box, the second combobox loads and have the value/Text "0" selected? I don't know where it comes from? If I display the drop down list, I don't have this value in it
  3. By default, I'm seeing my place holders, but how can I make that they are not selectable?
  4. What is the option to don't accept a written text, that isn't in the list?(a dropdown list with the contains search of the combo box)

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 24 May 2012, 10:49 AM
Hello Julien,

 
Straight upto your questions:

#1: I tried to reproduce the depicted using this online demo, but to no avail. Let me know if I am missing something.

#2: The ComboBox component is designed to allow custom values along with the predefined ones. I believe that the combobox's value is set to "0" when there are no items and that is why the "0" is shown. I will need a simple test project, which replicates the problem. Thus I will be able to observe it locally (and the returned data) and advice you further.

#3: This is not supported. Placeholder functionality of the ComboBox adds item in the begining of the list.

#4: As I mentioned the ComboBox is desinged to allow custom values. In order to achieve your goal you will need to wire the change event and prevent entering of a custom values:

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


Kind regards,
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.
Tags
ComboBox
Asked by
Julien
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or