页面加载时,我的嵌套模板列未出现在我的标记中。我正在尝试在另一个父网格的 DetailView 中加载带有模板列的网格。我可以看到我的数据正在传递,并且显然出现了 UnitPeriod 的“名称”,但在我的模板列中没有任何内容,因此看起来数据正在传递到网格中。我用萤火虫检查了源代码,该列总是加载为空。任何人都可以发现为什么?
<div>
@(Html.Telerik().Grid<RentableUnit>()
.Name("RentableUnits")
.Columns(columns =>
{
columns.Bound(e => e.UnitID).Hidden();
columns.Bound(e => e.Name).Width(75);
})
.ClientEvents(events => events.OnRowDataBound("employees_onRowDataBound")
.OnDetailViewExpand("unit_onDetailViewExpand")
.OnDetailViewCollapse("unit_onDetailViewCollapse"))
.DetailView(details => details.ClientTemplate(
Html.Telerik().Grid<UnitPeriod>()
.Name("UnitPeriod_<#= UnitID #>")
.Columns(columns =>
{
columns.Bound(o => o.Name);
columns.Template(@<text>
@foreach (Day day in item.Days)
{
if (!day.IsRentable)
{
<img src="../../Content/Images/Houses/icon_lokad.png"/>
}
else
{
<img src="../../Content/Images/Houses/icon_opid.png"/>
}
}
</text>);
})
.ClientEvents(events => events.OnRowDataBound("orders_onRowDataBound"))
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("SelectedUnitPeriod", "Home", new { unitId = "<#= UnitID #>" }))
.ToHtmlString()
))
.DataBinding(dataBinding => dataBinding.Ajax().Select("RentableUnits", "Home"))
.Sortable()
)
</div>
<script type="text/javascript">
var derpinski = "";
function expandFirstRow(grid, row) {
if (grid.$rows().index(row) == 0) {
grid.expandRow(row);
}
}
function loadTabGridContent(e) {
var url = '/Home/TabGridContent/';
$.ajax({
type: 'GET',
dataType: 'html',
url: url,
success: function (data) {
alert('success');
$('#TabGridContent').html(data);
}
});
}
function employees_onRowDataBound(e) {
var grid = $(this).data('tGrid');
expandFirstRow(grid, e.row);
}
function orders_onRowDataBound(e) {
var grid = $(this).data('tGrid');
expandFirstRow(grid, e.row);
}
function unit_onDetailViewExpand(e) {
var mstRow = e.masterRow;
var unitNumber = mstRow.cells[1].innerHTML;
derpinski = derpinski + unitNumber + ",";
}
function unit_onDetailViewCollapse(e) {
var mstRow = e.masterRow;
var unitNumber = mstRow.cells[1].innerHTML;
derpinski = derpinski.replace(unitNumber + ",", "");
}