这是来自telerik的典型示例,我尝试为嵌套网格创建模板但没有成功
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(110);
})
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("HierarchyBinding_Employees", "Grid"))
)
.Events(events => events.DataBound("dataBound"))
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name("grid_#=EmployeeID#")
.Columns(columns =>
{
columns.Bound(o => o.OrderID).Width(110);
columns.Bound(o => o.ShipCountry).Width(110);
columns.Bound(o => o.ShipName).Width(200);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
)
.ToClientTemplate()
)
</script>
如何为嵌套网格创建客户端模板?因为columns.Bound(o => o.OrderID).ClientTemplate("#=OrderID# - #=ShipName#")
不起作用。
答案 0 :(得分:0)
尝试在没有主题标签的情况下使用 columns.Bound(o =&gt; o.OrderID).ClientTemplate(“OrderID - ShipName”)
答案 1 :(得分:0)
有点晚了,但对于也搜索此答案的任何人:
转义模板表达式,在子/详细信息上下文中进行评估
例如:
columns.Bound(o => o.OrderID).ClientTemplate("\\#=OrderID\\# - \\#=ShipName\\#")