Cascade DropDownList keep selected value after initial loading

5 posts, 0 answers
  1. Luciano Kaesemodel
    Luciano Kaesemodel avatar
    26 posts
    Member since:
    Apr 2007

    Posted 11 Dec 2013 Link to this post

    Hey...

    I´m developing a CRUD application and I have a cascade ddl working fine in my Create view :
    @Html.Kendo().DropDownListFor(model => model.CarSelected).BindTo(Model.Cars)
     
    @(Html.Kendo().DropDownListFor(x =>           x.CarModelSelected).DataTextField("Name").DataValueField("Id")
          .Enable(false).AutoBind(false).OptionLabel("Select"))
          .CascadeFrom("CarSelected")     
          .DataSource(source => source.Read(read => read.Action("CarModels", "Car")
                      .Data("filter")).ServerFiltering(true))
    That works great...

    But in a Edit view, I have to previous load the car model selected, so I have something like that :
    public ActionResult Edit(int id)
    {
          var car = repository.load(id);
          CarVm carVm = car.InjectFrom(car);
          ...
          carVm.CarModelSelected = car.Model.Id;
     
          return View(carVm);
    }
    It works great and my inital Edit view is loaded fine...
    Now when I change the car, it loads all car model (cascade) but the CarModelSelected keep the inital value, and the CarModel DropDown dont reset to OptionLabel "Select" .

    So, If open a View with :Car A Model AB, change car to "Select", and after select Car A again, the model AB will be selected automatically

    How can I fix that? 

    Thanks



  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 12 Dec 2013 Link to this post

    Hello Luciano,

    Here is a quote of the answer to the support ticket opened on the same subject:

    Thank you for contacting us. The cascading functionality was designed to persist widget's value if it can be found in the data which the widget is bound to. Nevertheless, we decided to change this behavior and to reset child's value when user triggers the cascade. This change is available in the latest internal build of Kendo UI. Please download it and give it a try. Let me know if the problem still persists.

    I will suggest you continue our discussion in the support thread to avoid any duplication.

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mikhail
    Mikhail avatar
    2 posts
    Member since:
    Jul 2014

    Posted 04 May 2015 in reply to Georgi Krustev Link to this post

    Hello,

    I am wondering the reverse here.  Is there a way, after a cascade is triggered, to actually make the previously selected value persist if it can be found in the data which the dropdownlist is bound to? 

    Regards,
    Mike
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 06 May 2015 Link to this post

    Hi Mike,

    You can subscribe to the change event and store the values when it is triggered. Then, you can try restoring them once the cascade event is triggered.

    Regards,
    Alexander Popov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Mikhail
    Mikhail avatar
    2 posts
    Member since:
    Jul 2014

    Posted 07 May 2015 in reply to Alexander Popov Link to this post

    Simple enough and worked perfectly. Thank you Alexander!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready