为什么 kendo ui 示例的下拉列表模板 ASP.NET MVC 5 不 运行 对?
Why The DropDown list template of kendo ui sample for ASP.NET MVC 5 dont run right?
我将下拉模板用于 kendo ui Grid.this 例如 ASP.NET MVC
但是当点击下拉菜单时,它会显示不是下拉菜单的 ID 和名称。
我复制并替换了代码,但没有显示 Id 输入和名称输入的下拉菜单。
这个例子的 link 是:
https://demos.telerik.com/aspnet-mvc/grid/editing-custom
我的editing_custom.cshtml:
@using Microsoft.AspNet.Identity.EntityFramework;
@using UserManagerSample.KendoDropDown.KendoDropViewModel;
@using Kendo.Mvc.UI
<script
src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.aspnetmvc.min.js">
</script>
@(Html.Kendo().Grid<ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p =>
p.Category).ClientTemplate("#=Category.CategoryName#").Width(180);
columns.Bound(p => p.UnitPrice).Width(130);
columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.ProductID);
model.Field(p => p.ProductID).Editable(false);
model.Field(p => p.Category).DefaultValue(
ViewData["defaultCategory"] as CategoryViewModel);
})
.PageSize(20)
.Read(read => read.Action("EditingCustom_Read", "Grid"))
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
.Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Grid"))
)
)
和我的 ClintCategory.cshtml:
@using UserManagerSample.KendoDropDown.KendoDropViewModel;
@using Kendo.Mvc.UI;
@model CategoryViewModel
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
这是我最终的观点:
https://imgur.com/a/5gVX6f2
提前致谢
1-在view/shared/EditTemplates中创建一个文件夹并将其名称更改为EditTemplates
2-将 ClintCategory.cshtml 复制到 EditTemplates
3-添加 EditorTemplateName("ClintCategory")
columns.Bound(p =>
p.Category).ClientTemplate("#=Category.CategoryName#").EditorTemplateName("ClintCategory").Width(180)
并更改 ClintCategory.cshtml
@(Html.Kendo().DropDownListFor(m => m.CategoryName)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
运行 尽情享受吧:)
我将下拉模板用于 kendo ui Grid.this 例如 ASP.NET MVC 但是当点击下拉菜单时,它会显示不是下拉菜单的 ID 和名称。 我复制并替换了代码,但没有显示 Id 输入和名称输入的下拉菜单。 这个例子的 link 是: https://demos.telerik.com/aspnet-mvc/grid/editing-custom
我的editing_custom.cshtml:
@using Microsoft.AspNet.Identity.EntityFramework;
@using UserManagerSample.KendoDropDown.KendoDropViewModel;
@using Kendo.Mvc.UI
<script
src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.aspnetmvc.min.js">
</script>
@(Html.Kendo().Grid<ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p =>
p.Category).ClientTemplate("#=Category.CategoryName#").Width(180);
columns.Bound(p => p.UnitPrice).Width(130);
columns.Command(command => command.Destroy()).Width(150);
})
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.ProductID);
model.Field(p => p.ProductID).Editable(false);
model.Field(p => p.Category).DefaultValue(
ViewData["defaultCategory"] as CategoryViewModel);
})
.PageSize(20)
.Read(read => read.Action("EditingCustom_Read", "Grid"))
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
.Destroy(destroy => destroy.Action("EditingCustom_Destroy", "Grid"))
)
)
和我的 ClintCategory.cshtml:
@using UserManagerSample.KendoDropDown.KendoDropViewModel;
@using Kendo.Mvc.UI;
@model CategoryViewModel
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
这是我最终的观点: https://imgur.com/a/5gVX6f2
提前致谢
1-在view/shared/EditTemplates中创建一个文件夹并将其名称更改为EditTemplates
2-将 ClintCategory.cshtml 复制到 EditTemplates
3-添加 EditorTemplateName("ClintCategory")
columns.Bound(p =>
p.Category).ClientTemplate("#=Category.CategoryName#").EditorTemplateName("ClintCategory").Width(180)
并更改 ClintCategory.cshtml
@(Html.Kendo().DropDownListFor(m => m.CategoryName)
.DataValueField("CategoryID")
.DataTextField("CategoryName")
.BindTo((System.Collections.IEnumerable)ViewData["categories"])
)
运行 尽情享受吧:)