Hi,
We have recently upgraded our Kendo MVC version to 2024.2.514.462. The normal upgrade works fine but I was trying to implement the `CSP template` after removing the `unsafe-eval` from the tag as it was announced in 2023 version.
I was following the example given in CSP template and tried changing the template defined in treeview (also as shown in the documentation):-
sideNavList.kendoTreeView({
/*template: "<span id='#= item.id #' class='navText'> #= item.text# </span>",*/
template: ({ items }) => `<span id='kendo.htmlEncode(items.id)' class='navText'> kendo.htmlEncode(items.text) </span>`,
dataSource: hierarchicalLeftNavData,
It is not throwing error but it's not able to recognize the `item` and rendering the template as:-
<span id="kendo.htmlEncode(items.id)" class="navText"> kendo.htmlEncode(items.text) </span>
Am I missing anything?
Hi Rahul,
Please try to use the "item" property instead of the "items" property as this syntax is getting a property of the parameter object and is not a simple variable, meaning the correct naming is important.
sideNavList.kendoTreeView({
/*template: "<span id='#= item.id #' class='navText'> #= item.text# </span>",*/
template: ({ item }) => `<span id='kendo.htmlEncode(item.id)' class='navText'> kendo.htmlEncode(item.text) </span>`,
dataSource: hierarchicalLeftNavData
<span id="kendo.htmlEncode(item.id)" class="navText"> kendo.htmlEncode(item.text) </span>
Regards,
Peter Milchev
Progress Telerik
Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024