简体   繁体   English

Kendo Cascade DropDownList MVC在初始加载后保持选定的值

[英]Kendo Cascade DropDownList MVC keep selected value after initial loading

I´m developing a CRUD application and I have a cascade dropdownlist working fine in my Create view : 我正在开发一个CRUD应用程序,并且在我的Create视图中可以正常工作的层叠下拉列表为:

@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" . 它工作得很好,我的inital编辑视图已正常加载...现在,当我更换汽车时,它将加载所有汽车模型(级联),但CarModelSelected保留初始值,并且CarModel DropDown不会重置为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 因此,如果使用:Car A AB型打开视图,将汽车更改为“选择”,然后再次选择Car A后,将自动选择AB型

How can I fix that? 我该如何解决?

Thanks 谢谢

It was fixed in the newest internal Kendo build 它在最新的内部剑道版本中修复

Paul 保罗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM