单元格中带有自定义下拉列表的网格示例 - 它如何呈现下拉列表?
Grid example with custom dropdownlist in cell - how does it render a dropdownlist?
我正在尝试从用于在网格行的下拉列表中显示预定义项目列表的编辑器模板进行转换。这可行,但我需要为不同的网格定制列表,因为我的应用程序的不同区域之间的数据不相同。
所以我正在查看客户端模板并以某种方式定义我自己的模板。
在此示例中,我不确定 "categories" 列表在视图中的什么位置使用。
此示例中是否使用了此列表?
由于具有作为列表的 "nested" 属性,下拉列表如何在行中呈现?
http://demos.telerik.com/aspnet-mvc/grid/editing-custom
private void PopulateCategories()
{
var dataContext = new SampleEntities();
var categories = dataContext.Categories
.Select(c => new CategoryViewModel {
CategoryID = c.CategoryID,
CategoryName = c.CategoryName
})
.OrderBy(e => e.CategoryName);
ViewData["categories"] = categories;
ViewData["defaultCategory"] = categories.First();
}
我想知道的是这一行:
ViewData["categories"] = 类别;
为什么需要这个以及它的用途是什么?我看不到它在控制器或视图中的使用 - 除非读取操作默认使用它或某种约定?
ViewData["categories"]
用于编辑器模板。这个文件没有显示在演示站点上,但你可以在你应该从安装程序获得的离线演示中看到它:
/Views/grid/EditorTemplates/ClientCategory.cshtml
内容如下:
@model Kendo.Mvc.Examples.Models.CategoryViewModel
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
更多信息:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates
我正在尝试从用于在网格行的下拉列表中显示预定义项目列表的编辑器模板进行转换。这可行,但我需要为不同的网格定制列表,因为我的应用程序的不同区域之间的数据不相同。
所以我正在查看客户端模板并以某种方式定义我自己的模板。
在此示例中,我不确定 "categories" 列表在视图中的什么位置使用。
此示例中是否使用了此列表?
由于具有作为列表的 "nested" 属性,下拉列表如何在行中呈现?
http://demos.telerik.com/aspnet-mvc/grid/editing-custom
private void PopulateCategories()
{
var dataContext = new SampleEntities();
var categories = dataContext.Categories
.Select(c => new CategoryViewModel {
CategoryID = c.CategoryID,
CategoryName = c.CategoryName
})
.OrderBy(e => e.CategoryName);
ViewData["categories"] = categories;
ViewData["defaultCategory"] = categories.First();
}
我想知道的是这一行:
ViewData["categories"] = 类别;
为什么需要这个以及它的用途是什么?我看不到它在控制器或视图中的使用 - 除非读取操作默认使用它或某种约定?
ViewData["categories"]
用于编辑器模板。这个文件没有显示在演示站点上,但你可以在你应该从安装程序获得的离线演示中看到它:
/Views/grid/EditorTemplates/ClientCategory.cshtml
内容如下:
@model Kendo.Mvc.Examples.Models.CategoryViewModel
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
更多信息:
http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates