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

Cascade DropDownList keep selected value after initial loading

4 Answers 634 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Luciano Kaesemodel
Top achievements
Rank 1
Luciano Kaesemodel asked on 11 Dec 2013, 11:30 AM
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



4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 12 Dec 2013, 03:39 PM
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!
0
Mikhail
Top achievements
Rank 1
answered on 04 May 2015, 07:01 PM
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
0
Alexander Popov
Telerik team
answered on 06 May 2015, 02:51 PM
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.

 
0
Mikhail
Top achievements
Rank 1
answered on 07 May 2015, 03:05 PM
Simple enough and worked perfectly. Thank you Alexander!
Tags
DropDownList
Asked by
Luciano Kaesemodel
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Mikhail
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or