I can't seem to get nested templates to work. Perhaps this isn't even supported? I am seeing the following in console.
Uncaught ReferenceError: BotName is not defined
I believe this is related to the last file shown, _BotGrid. This grid should display a link to the details page for the Bot, however, the ClientTemplate("#=BotName#") does not appear to be working. My guess is the templating engine is looking for BotName to come from the parent grids model, and not from the Bot Grids model. Is there a work around or a way to make this work?
Files
TopLevelGrid.cshtml
@model System.Collections.Generic.List<Subscriber>
@(Html.Kendo().Grid<Subscriber>()
.Name(ViewData["Name"].ToString())
.ClientDetailTemplateId("gridDetailsTemplate")
.DataSource(dataSource =>
dataSource
.Ajax()
.Sort(sortOrder => sortOrder.Add(s => s.Name).Ascending())
.PageSize(20)
.Read(
read => read.Action("_Grid", "Subscribers", new { Area = "Admin" })
)
)
.Columns(columns =>
{
columns
.Bound(s => s.Name)
.ClientTemplate("<a href=\"\\#/Detail/#=Id#\">#=Name#</a>")
.Title("Subscriber")
.Width("100%");
columns
.Bound(s => s.Active)
.Filterable(false)
.HeaderHtmlAttributes(new { style = "text-align:center; " })
.HtmlAttributes(new { style = "text-align:center; " })
.ClientTemplate("<input type=\"checkbox\" #=Active ? checked='checked' : '' # disabled=\"disabled\" />");
})
.Filterable()
.Sortable()
.Pageable()
)
@Html.Partial("_GridDetail")
_GridDetail.cshtml partial view -- This part seems to work fine if I remove the _BotGrid partial view
<script id="gridDetailsTemplate" type="text/kendo-tmpl">
<ul id="subscriber-tabs-#=Id#" class="nav nav-tabs">
<li class="active"><a href="\\#subscriber-bots-#=Id#" data-toggle="tab">Bots</a></li>
<li class=""><a href="\\#subscriber-markets-#=Id#" data-toggle="tab">Markets</a></li>
<li class=""><a href="\\#subscriber-report-scheduling-#=Id#" data-toggle="tab">Online Report Schedules</a></li>
</ul>
<div id="subscriber-tab-content-#=Id#" class="tab-content">
<div class="tab-pane fade active in" id="subscriber-bots-#=Id#">
@Html.Partial("_BotGrid", new ViewDataDictionary { { "SubscriberID", "#=Id#" } })
</div>
</div>
</script>
_BotGrid.cshtml partial view
@(Html.Kendo().Grid<AMS.DTO.Bot>()
.Name("Bots-" + ViewData["SubscriberID"].ToString())
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sortOrder => sortOrder.Add(b => b.BotName).Ascending())
.Model(model => model.Field(m => m.BotName))
.PageSize(20)
.Read(
read => read.Action("_BotGrid", "Subscribers", new { Area = "Admin", id = ViewData["SubscriberID"].ToString() })
)
)
.Columns(columns =>
{
columns.Bound(b => b.BotName)
.ClientTemplate("#=BotName#")
.Title("Name");
columns
.Bound(b => b.CreateDate)
.Filterable(false)
.Format("{0:MM/dd/yyyy}")
.Title("Created");
}
)
.Sortable()
.Pageable()
.Filterable()
.Scrollable(scrolling =>
scrolling.Height(200)
)
.ToClientTemplate()
)
Thanks!
Uncaught ReferenceError: BotName is not defined
I believe this is related to the last file shown, _BotGrid. This grid should display a link to the details page for the Bot, however, the ClientTemplate("#=BotName#") does not appear to be working. My guess is the templating engine is looking for BotName to come from the parent grids model, and not from the Bot Grids model. Is there a work around or a way to make this work?
Files
TopLevelGrid.cshtml
@model System.Collections.Generic.List<Subscriber>
@(Html.Kendo().Grid<Subscriber>()
.Name(ViewData["Name"].ToString())
.ClientDetailTemplateId("gridDetailsTemplate")
.DataSource(dataSource =>
dataSource
.Ajax()
.Sort(sortOrder => sortOrder.Add(s => s.Name).Ascending())
.PageSize(20)
.Read(
read => read.Action("_Grid", "Subscribers", new { Area = "Admin" })
)
)
.Columns(columns =>
{
columns
.Bound(s => s.Name)
.ClientTemplate("<a href=\"\\#/Detail/#=Id#\">#=Name#</a>")
.Title("Subscriber")
.Width("100%");
columns
.Bound(s => s.Active)
.Filterable(false)
.HeaderHtmlAttributes(new { style = "text-align:center; " })
.HtmlAttributes(new { style = "text-align:center; " })
.ClientTemplate("<input type=\"checkbox\" #=Active ? checked='checked' : '' # disabled=\"disabled\" />");
})
.Filterable()
.Sortable()
.Pageable()
)
@Html.Partial("_GridDetail")
_GridDetail.cshtml partial view -- This part seems to work fine if I remove the _BotGrid partial view
<script id="gridDetailsTemplate" type="text/kendo-tmpl">
<ul id="subscriber-tabs-#=Id#" class="nav nav-tabs">
<li class="active"><a href="\\#subscriber-bots-#=Id#" data-toggle="tab">Bots</a></li>
<li class=""><a href="\\#subscriber-markets-#=Id#" data-toggle="tab">Markets</a></li>
<li class=""><a href="\\#subscriber-report-scheduling-#=Id#" data-toggle="tab">Online Report Schedules</a></li>
</ul>
<div id="subscriber-tab-content-#=Id#" class="tab-content">
<div class="tab-pane fade active in" id="subscriber-bots-#=Id#">
@Html.Partial("_BotGrid", new ViewDataDictionary { { "SubscriberID", "#=Id#" } })
</div>
</div>
</script>
_BotGrid.cshtml partial view
@(Html.Kendo().Grid<AMS.DTO.Bot>()
.Name("Bots-" + ViewData["SubscriberID"].ToString())
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sortOrder => sortOrder.Add(b => b.BotName).Ascending())
.Model(model => model.Field(m => m.BotName))
.PageSize(20)
.Read(
read => read.Action("_BotGrid", "Subscribers", new { Area = "Admin", id = ViewData["SubscriberID"].ToString() })
)
)
.Columns(columns =>
{
columns.Bound(b => b.BotName)
.ClientTemplate("#=BotName#")
.Title("Name");
columns
.Bound(b => b.CreateDate)
.Filterable(false)
.Format("{0:MM/dd/yyyy}")
.Title("Created");
}
)
.Sortable()
.Pageable()
.Filterable()
.Scrollable(scrolling =>
scrolling.Height(200)
)
.ToClientTemplate()
)
Thanks!