Hi team,
As the question says, Im trying to define my template content as part of an html data attribute, see dojo: https://dojo.telerik.com/UxAPOXeV
But i get a syntax error when the widget is initialized.
Please advise.
Thanks,
Grant
5 Answers, 1 is accepted
Hi Grant,
Thank you for the provided Dojo sample that demonstrates the syntax error. Indeed, within the data-template attribute, an external kendo.template has to be passed. Here is an example:
data-template="template"
// ... ...
<script type="text/kendo-x-tmpl" id="template">
<div>
Item template for #:name#
</div>
</script>
Check out the modified sample here:
https://dojo.telerik.com/ezofEhUm
I hope this helps.
Regards,
Tsvetomir
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.

Thanks Tsvetomir,
This is perfect.Please can you link me to the docs where this is covered, I couldn't find this particular scenario.
Also see that sometimes the script type is "text/kendo-x-tmpl" and sometimes its "text/kendo-x-template", is one being deprecated, is one more correct than the other, why the change, does it matter?
Thanks a bunch,
Grant

I have another related question.
Please look at this dojo, https://dojo.telerik.com/ikebUlIY/4
Why does Template #1 work but Template #2 has syntax errors?
Thanks

Hi Grant,
There is a difference between the "#=#" and "##" syntax. The first one is used when a template should be built based on a specific field or object, however, JavaScript logic will not be executed. The second one is used when JavaScript logic has to be executed - in the current case, the placeholders "{0} {1}" and the kendo.format() method require JavaScript. Alternatively, you could use the following:
<script type="text/x-kendo-template" id="groupByName-templateHeader2" data-th-inline="javascript">
# return kendo.format("Total Tasks for {0}: {1}", value, aggregates.tasks.sum); #
</script>
More information on the templates could be found here:
- https://docs.telerik.com/kendo-ui/framework/templates/overview
- https://docs.telerik.com/kendo-ui/api/javascript/ui/listview/configuration/template
Regards,
Tsvetomir
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.