This is a migrated thread and some comments may be shown as answers.

Recursive kendo template

1 Answer 172 Views
Templates
This is a migrated thread and some comments may be shown as answers.
devster
Top achievements
Rank 1
devster asked on 14 May 2014, 08:01 AM
Hey,

I have a grid that has a clientdetailtemplate. In that template, i use another grid, that would call the same template again untill maybe 3 levels down.
Is that possible? I get invalid client template, but thats maybe it is just not possible by design. When i add .toclienttemplate on the grid, it does not give an error, but nothing seems to happen.

<div id="dvResults" class="searchResults col-md-6 col-md-offset-3">
    <div id="resultGrid">
        @(Html.Kendo().Grid(Model.SearchDetails)
              .Name("grdSearch$Results")
              .HtmlAttributes(new { @class = "grdSearchResults" })
              .Columns(column =>
              {
                  column.Bound(x => x.Icon).Template(@<text><img src="@item.Icon" class="searchicon" /></text>).Width(16);
                  column.Bound(x => x.Name).Template(
                      @<text><a onclick="SelectEntity('@item.CustomerId','@item.PremisesId','@item.InvoiceStructureId')">@item.Name</a>
                           @if (@item.IsCustomerLevel)
                           {
                               <br /><text>@item.SearchCriteria : @item.Field</text>
                           }</text>).Title("");
              })
                                         .ClientDetailTemplateId("gridDetailTemplate")
              )
    </div>
</div>
 
<script id="gridDetailTemplate" type="text/kendo-tmpl">
 
    @(Html.Kendo().Grid<SearchDetailModel>("#=Children#")
        .Name("GrdSearchDetails_#=Id#")
        .HtmlAttributes(new { @class = "grdSearchResults" })
        .Columns(column =>
        {
            column.Bound(x => x.Icon);
        }).ClientDetailTemplateId("gridDetailTemplate")
         
    )
 
 
</script>

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 May 2014, 08:15 AM
Hello,

The ToClientTemplate method should always be used for controls that are included in a template. Otherwise, the "#" character used at least for the id selector will not be escaped by the control and the template will be invalid. 
As for the case when the method is not called - what is the value of the "Children" property. The detail grid will not be initialized if the value of the property is not valid for an element ID.


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
devster
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or