【发布时间】:2016-02-23 18:43:50
【问题描述】:
我在 MVC 中工作,并在我们的前端使用 Kendo。我们有一个具有 Enum 值的模型。在我们的前端,我正在尝试生成一个 Kendo 网格,并能够从网格中的下拉列表中修改 Enum 的值。
型号:
public class TankModel:FieldDeviceModel
{
//Other properties not shown
public TankLevel Level { get; set; }
}
控制器:
public class FieldSimulationController : Controller
{
public ActionResult Index()
{
return View();
}
//Other methods not shown
public ActionResult TanksTab()
{
return PartialView("Tanks");
}
}
查看:
@(Html.Kendo().Grid<TankModel>()
.Name("TanksGrid")
.Columns(maincolumns =>
{
maincolumns.ForeignKey(t => t.Level,
new SelectList(EnumHelper.GetSelectList(
typeof(TankLevel)))).EditorTemplateName("ClientLevel").Width(200);
})
.HtmlAttributes(new { style = "height: 550px; width:auto; text-align:center" })
.Sortable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Read(read => read
.Action("Devices_Read", "FieldSimulation") // Set the action method which will return the data in JSON format
.Data("GetTankType") // Specify the JavaScript function which will return the data
)
.Update(update => update.Action("Devices_Update", "FieldSimulation").Type(HttpVerbs.Post))
.PageSize(20)
.Model(model =>
{
model.Field(t => t.Level);
})
)
)
现在,我正在使用 Kendo 的 ForeignKey 列类型。这似乎没有给出任何错误,但网格没有显示下拉列表
我还尝试了 SO 中其他地方的解决方案,例如 here,结果相同,网格中没有出现任何列。
另外,我没有看到任何表明问题所在的 JS 错误。
感谢您的宝贵时间和任何帮助。
【问题讨论】:
标签: c# asp.net-mvc kendo-ui kendo-grid