我的.net mvc应用程序的详细信息模板中有另一个网格的kendo网格。子网格包含字段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>
答案 0 :(得分:0)
尝试用斜线逃避尖锐的符号。目前它由外部网格评估,因为主网格没有这样的字段,它会抛出此错误。
myFunction(\\#=Id\\#)