我的 .net mvc 应用程序的详细模板中有一个剑道网格和另一个网格。子网格具有 Id、Name、Total 和 Score 字段。我希望能够定义这样的列
columns.Template(@<text></text>).ClientTemplate("<a href=\"#\" onclick=\"myFunction(#=Id#)\">LinkText</a>");
有趣的部分是myFunction(#=Id#)
,当我这样做时,我收到一个错误,说 Id 未定义。它适用于主网格但不适用于子网格,有没有办法访问子网格的字段?谢谢。
这是我的看法:
@( Html.Kendo().Grid<WinStream.WebUI.Models.ServiceItemGridModel>()
.Name("ManageSIGrid")
.Columns(columns =>
{
columns.Template(@<text></text>).ClientTemplate(
"#=showSIFlag(Flagged)#" +
"#=showSILock(Locked)#" +
"#=showSIDeactive(Activated)#"
).Width(75);
columns.Bound(o => o.Id).Width(50);
columns.Bound(o => o.Name).Width(160);
columns.Bound(o => o.Customer).Width(150);
columns.Bound(o => o.Location).Width(150);
columns.Bound(o => o.City);
columns.Bound(o => o.State).Width(60);
columns.Bound(o => o.Type);
columns.Bound(o => o.Style);
columns.Bound(o => o.Material);
})
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(true)
.Read(read => read.Action("ReadServiceItems", "Bids", new { bidId = Model.BidID }))
.Model(model => model.Id(c => c.Id))
)
.Sortable()
.Filterable(f => f
.Extra(false)
)
.ClientDetailTemplateId("biditemgrid")
.Navigatable()
.Pageable(page => page.Refresh(true).PageSizes(true))
.Scrollable(scroll => scroll.Virtual(true).Height(300))
.Selectable(select => select.Mode(GridSelectionMode.Multiple))
.AutoBind(true)
.Events(events => events.DataBound("dataBound"))
)
<script id="biditemgrid" type="text/kendo-tmpl">
@( Html.Kendo().Grid<WinStream.WebUI.Models.BidItemGridModel>()
.Name("BidItemGrid")
.Columns(columns =>
{
columns.Bound(o => o.Id).Width(50);
columns.Bound(o => o.Name).Width(160);
columns.Bound(o => o.Total).Width(75).Title("Total Price");
columns.Bound(o => o.Score).Width(75);
.Sortable()
.Filterable(f => f
.Extra(false)
)
.Navigatable()
.Pageable()
.Selectable(select => select.Mode(GridSelectionMode.Multiple))
.ToolBar(toolbar => toolbar.Template(
"<p class=\"float-left big-text no-margin-bottom\">Vendors</p>"
))
.DataSource(data => data
.Ajax()
.ServerOperation(false)
.PageSize(5)
.Read(read => read.Action("ReadBidItems", "Bids", new { bidId = Model.BidID, siId = "#=Id#" }))
.Model(model => model.Id(c => c.Id))
)
.ToClientTemplate()
)
</script>