This question is locked. New answers and comments are not allowed.
Hi,
We are using the Telerik MVC controls from Nuget. Great so far, but ran into something I can't figure out.
So we have two combo boxes, Plants and Units, with Plants cascading into Units.
I'll post the code below. My problem is, when a plant is selected and Units reloads with the correct values, it ALWAYS sets the selected valeu to be "0" text. When you open the drop down it's not an option to pick, but it sets it be default every time. When we switch the control to be a dropdownlist it works perfectly, however our users wants the combo box and not the drop down. I've debugged the fetch for the unit data and it's bringing back the proper values, no extra 0 anywhere.
Have you telerik guys seent his before or am I doing something obviously worng? Any help is appreciated, thanks :)
We are using the Telerik MVC controls from Nuget. Great so far, but ran into something I can't figure out.
So we have two combo boxes, Plants and Units, with Plants cascading into Units.
I'll post the code below. My problem is, when a plant is selected and Units reloads with the correct values, it ALWAYS sets the selected valeu to be "0" text. When you open the drop down it's not an option to pick, but it sets it be default every time. When we switch the control to be a dropdownlist it works perfectly, however our users wants the combo box and not the drop down. I've debugged the fetch for the unit data and it's bringing back the proper values, no extra 0 anywhere.
Have you telerik guys seent his before or am I doing something obviously worng? Any help is appreciated, thanks :)
<div class="editor"> @Html.LabelFor(model => model.Plant) @( Html.Telerik().ComboBoxFor(model => model.PlantId) .BindTo(new SelectList((IEnumerable<MDL.Models.Plant>)ViewBag.PossiblePlants, "PlantId", "Description")) .Placeholder("Select Plant...") .CascadeTo("UnitId") .SelectedIndex(0) ) @Html.ValidationMessageFor(model => model.PlantId) </div> <div class="editor"> @Html.LabelFor(model => model.Unit) @( Html.Telerik().ComboBoxFor(model => model.UnitId) .DataBinding(binding => binding.Ajax().Select("_GetDropDownListUnits", "NewAnomaly")) .Placeholder("Select Unit...") .SelectedIndex(0) ) @Html.ValidationMessageFor(model => model.UnitId) </div>[HttpPost] public JsonResult _GetDropDownListUnits(int? PlantId) { return _GetUnits(PlantId); } private JsonResult _GetUnits(int? PlantID) { IQueryable<Unit> units = unitRepository.All; if (PlantID.HasValue) { units = units.Where(p => p.PlantId == PlantID.Value); } return Json(new SelectList(units, "UnitID", "Description"), JsonRequestBehavior.AllowGet); }