I am evaluating your software for purchase and have encountered the following problem. I am trying to create a grid which will have a dropdown list editor for one of its columns. According to the comment in the thread https://www.telerik.com/forums/grid-with-drop-down-not-working it should be sufficient to create a foreign key column and then provide the data necessary to populate the dropdown. This isn't working for me. The editor for the personid column should be a dropdown list, but it isn't. No errors are shown when the project is built nor when the web page is displayed. Here is my code:
ScheduleGrid.cshtml
@{
ViewData["Title"] = "Schedule";
}
<h2>Schedule</h2>
@(Html.Kendo().Grid<SessionItemModel>()
.Name("ScheduleGrid")
.DataSource(d => d
.Ajax()
.Batch(true)
.PageSize(7)
.ServerOperation(false)
.Model(model => { model.Id(p => p.pkey); })
.Read(r => r.Action("Read", "Schedule"))
.Update(u => u.Action("Update","Schedule"))
.Group(g => g.Add(p => p.daypart)))
.Columns(c => {
c.Bound(m => m.pkey).Visible(false);
c.Bound(m => m.sessionkey).Visible(false);
c.Bound(m => m.daypart).Title("Day Part").Visible(false);
c.Bound(m => m.type).Visible(false);
c.Bound(m => m.slot).Title("Slot");
c.ForeignKey(m => m.personid, (System.Collections.IEnumerable)ViewData["persons"], "personid", "name").Title("Name");
c.Bound(m => m.editable).Visible(false);
})
.Groupable(false)
.Pageable()
.Editable(e => e.Mode(GridEditMode.InCell))
)
ScheduleController.cs
public class ScheduleController : Controller {
private sessionsRepository repo = new sessionsRepository();
public IActionResult Index() {
ViewData["persons"] = repo.GetPersons();
return View("ScheduleGrid");
}
public ActionResult Read([DataSourceRequest] DataSourceRequest request) {
List<SessionItemModel> sessions = repo.GetItems();
DataSourceResult result = sessions.ToDataSourceResult(request);
return Json(result);
}
[HttpPost]
public ActionResult Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<SessionItemModel> items) {
// update sessions here
List<SessionItemModel> sessions = repo.GetItems();
DataSourceResult result = sessions.ToDataSourceResult(request);
return Json(result);
}
}