【发布时间】:2015-04-27 07:22:13
【问题描述】:
鉴于this UI for MVC example,我如何在客户端模板中为详细模板引用数据源中的项目?
例如,示例中的 Detail Template 看起来像这样......
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip()
.Name("tabStrip_#=EmployeeID#")
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text("Orders").Content(@<text>
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name("grid_#=EmployeeID#")
.Columns(columns =>
{
columns.Bound(o => o.OrderID).Title("ID").Width(56);
columns.Bound(o => o.ShipCountry).Width(110);
columns.Bound(o => o.ShipAddress);
columns.Bound(o => o.ShipName).Width(190);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("HierarchyBinding_Orders", "Grid", new { employeeID = "#=EmployeeID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate())
</text>
);
items.Add().Text("Contact Information").Content(
"<div class='employee-details'>" +
"<ul>" +
"<li><label>Country:</label>#= Country #</li>" +
"<li><label>City:</label>#= City #</li>" +
"<li><label>Address:</label>#= Address #</li>" +
"<li><label>Home Phone:</label>#= HomePhone #</li>" +
"</ul>" +
"</div>"
);
})
.ToClientTemplate())
</script>
假设绑定到的列,比如说,ShipAddress 需要使用 ClientTemplate 显示,写
columns.Bound(o => o.ShipAddress).ClientTemplate("#=ShipAddress#")
只会导致“Uncaught ReferenceError: ShipAddress is not defined”
那么,我如何获得详细模板的数据源项?
【问题讨论】:
标签: kendo-grid kendo-asp.net-mvc