Kendo ui 客户端详细信息模板中的下拉列表-剑道网格
我正在尝试在客户端模板中添加dropdownlist,但不知何故无法,有人能帮我吗Kendo ui 客户端详细信息模板中的下拉列表-剑道网格,kendo-ui,kendo-grid,kendo-asp.net-mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我正在尝试在客户端模板中添加dropdownlist,但不知何故无法,有人能帮我吗 columns.Bound(o => o.ImportFunctionText).ClientTemplate("# if (ImportFunction == 0) { # Account # } else if (ImportFunction == 1) { # Row # } #") .EditorTemplateName("DropDownList")
columns.Bound(o => o.ImportFunctionText).ClientTemplate("# if (ImportFunction == 0) { # Account # } else if (ImportFunction == 1) { # Row # } #")
.EditorTemplateName("DropDownList")
.EditorViewData(new
{
Id = "ImportFunction",
Data = ViewBag.dropDownList,
FieldName = "value:ImportFunction"
})
.Width(210)
.Title("Function");
谢谢。为了使用编辑器模板,您必须将编辑器模板作为部分视图存储在~/Views/Shared/EditorTemplates/tmp\u dropdown\u attribute.cshtml文件夹中 根据telerik asp net mvc文档,模板应如下所示:
@(Html.Kendo().DropDownList()
.Name("Employee") // Name of the widget should be the same as the name of the property
.DataValueField("EmployeeID") // The value of the dropdown is taken from the EmployeeID property
.DataTextField("EmployeeName") // The text of the items is taken from the EmployeeName property
.BindTo((System.Collections.IEnumerable)ViewData["employees"]) // A list of all employees which is populated in the controller
)
控制器应在生成视图的控制器方法中绑定viewdata容器,如下所示:
public ActionResult Index()
{
ViewData["employees"] = new NorthwindDataContext()
.Employees
.Select(e => new Employee
{
EmployeeID = e.EmployeeID,
EmployeeName = e.FirstName + " " + e.LastName
})
.OrderBy(e => e.EmployeeName);
return View();
}
如需进一步阅读,请参阅以下文件: