Unexpected Token "<" in grid template

1 Answer 609 Views
Grid
Dan
Top achievements
Rank 1
Veteran
Dan asked on 26 Aug 2021, 12:59 PM

I am using a nested grid. The nested grid is inside of script tags and looks like this. For some reason when rendering it throws "Unexpected Token '<'. Im unsure why. It renders fine if I pull it out and remove .ToClientTemplate()

<script id="template"> @(Html.Kendo().Grid<Student>() .Name("Student#=Student_ID#") .Width(1500) .HtmlAttributes(new { style="margin-right:20px;height: fit-content;font-size:small" }) .Columns(columns => {

columns.Bound(o => o.StudentName).Width(300) columns.Bound(o => o.TimeStamp).Width(300).Title("Date").Format("{0:G}"); columns.Bound(o => o.Details).Width(900); }) .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .PageSize(10) .Read(read => read.Action("GetDetails", "Grid", new{ studentName= "#=StudentName#" })) ) .Pageable(x => x.Refresh(true)) .Sortable() .ToClientTemplate() ) </script>


1 Answer, 1 is accepted

Sort by
0
Accepted
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 30 Aug 2021, 09:37 PM

Hi Dan,

First, thank you for sharing your template as this helped determine the issue.  

The template should include a type of text/kendo-tmpl or something similar like the implementation used in this Kendo UI Grid DetailTemplate Live Demo. 

<script id="template" type="text/kendo-tmpl">
           @(Html.Kendo().Grid<Student>()
                //...
                .ToClientTemplate()
           )

</script>

Please let me know if you have any questions.

Regards,
Patrick
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Dan
Top achievements
Rank 1
Veteran
commented on 31 Aug 2021, 05:29 PM

Ahh. Easy fix. This worked, thanks.
Patrick | Technical Support Engineer, Senior
Telerik team
commented on 31 Aug 2021, 06:10 PM

No problem Dan.  Happy to help! 
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Veteran
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or