Hey guys,
We have a big problem compiling Kendo templates which contain other Kendo widgets, e.g. a Grid.
We have the following template (simplified):
<script id="myTemplate" type="text/x-kendo-template">@(Html.Kendo().Grid<MyViewModel>() .Name("myGrid") .Columns(columns => { columns.Bound(c => c.Name); }))</script>The original template contains other dynamic data-bound values, e.g. "#=Id#"... thus we need a template approach! Now we want to compile this template, because we need to show it as content of a window:
<script type="text/javascript"> var myTemplate = kendo.template($("#myTemplate").html());</script>This should work fine, but Kendo gives us invalid JavaScript when compiling:
Invalid template... Generated code: var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='<div class="k-widget k-grid" id="myGrid"><table><colgroup><col /></colgroup><thead class="k-grid-header"><tr><th class="k-header" data-field="Name" data-index="0" data-title="Name" scope="col"><span class="k-link">Name</span></th></tr></thead><tbody><tr class="k-no-data"><td colspan="1"></td></tr></tbody></table></div><script>\n\tjQuery(function(){jQuery("';myGrid").kendoGrid({"columns":[{"title":"Name","field":"Name","encoded":true}],"scrollable":false,"autoBind":false,"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-server']){return 'aspnetmvc-server';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":""},"prefix":"channelsAssignGrid-"},"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"Name":{"type":"string"}}}}}});}); ;$kendoOutput+=;}return $kendoOutput;
Any ideas/solutions for this? I think we're not the first discovering this problem... is there any straight forward solution?
Thanks, Dimitrij