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

Set value in cascading dropdownlist

1 Answer 642 Views
This is a migrated thread and some comments may be shown as answers.
Mattias Hermansson
Top achievements
Rank 1
Mattias Hermansson asked on 07 May 2014, 10:46 AM

I'm trying to set the value of the cascading dropdownlist, i want to set the value that the model have in the second dropdownlist. The value seems to be set, but only after i first click on the second dropdownlist then i get the right "name" in the list. Anything i'm doing wrong?
                function contractorChanged() {
                        type: "POST",
                        url: '@Url.Action("GetContactPersons", "Permission")',
                        data: {
                            id: $("#ContractorId").val()
                        cache: false,
                        success: function (data) {
@(Html.Kendo().DropDownListFor(model => model.ContractorId)
              .HtmlAttributes(new { style = "width:100%; margin-bottom: 8px;" })
              .OptionLabel("Välj företag")
              .Events(e => e.DataBound("contractorChanged"))
              .DataSource(source =>
                  source.Read(read => { read.Action("GetConstructors", "Permission"); });
            @(Html.Kendo().DropDownListFor(model => model.ContractorPersonId)
              .HtmlAttributes(new { style = "width:100%" })
              .OptionLabel("Välj kontaktperson")

1 Answer, 1 is accepted

Sort by
Georgi Krustev
Telerik team
answered on 08 May 2014, 09:30 AM
Hello Mattias,

In general, the child combobox will try to filter its data source on parent cascade. If the child datasource's is empty after the filtration then its value will be cleared (check this demo, which demonstrates exactly this). I examined the posted code snippet, but I could not notice where the child combobox is bound. Is it with empty data source ? I would also suggest you check the offline demos part of the Telerik UI for ASP.NET MVC bundle. There you can find, examine and debug a cascading demo with remote binding.
If the problem still persists on your end, then I will need a runnable test project to investigate the problem further.

Georgi Krustev

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Mattias Hermansson
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question