0
當頁面加載時,我的嵌套模板列未出現在我的標記中。我正嘗試在另一個父網格的DetailView中加載一個帶有模板列的網格。我可以看到我的數據被傳遞,顯然UnitPeriod的「名稱」出現,但我的模板列中沒有任何內容,所以看起來數據正在傳遞到網格中。我用firebug檢查了源代碼,並且該列始終爲空。任何1可以找到原因嗎?Telerik Grid中的DetailView中的模板列MVC
<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 + ",", "");
}