Set value in cascading dropdownlist

2 posts, 0 answers
  1. Mattias Hermansson
    Mattias Hermansson avatar
    24 posts
    Member since:
    May 2010

    Posted 07 May 2014 Link to this post


    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")

  2. Georgi Krustev
    Georgi Krustev avatar
    3688 posts

    Posted 08 May 2014 Link to this post

    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.

  3. UI for ASP.NET AJAX banner
Back to Top