KendoUI Grid - how to declaratively set an MVVM data column template for an external template?

I am struggling with a setup grid declaring column external template

Here is my template

<script type="text/x-kendo-template" id="someTemplate"> <div> <label> ${firstName}</label> <label>${lastName}</label> </div> </script> 

and here the mesh ad

 <div data-role="grid" data-bind="source: people" data-columns='[ {"field": "firstName", "title": "Full Name", "template": "kendo.template($("#someTemplate"))" } ]'></div> 

And here JS Fiddle reproduces my problem: Play JSFiddle

+4
source share
2 answers

A few hours after the expiration, I found out that ....

template: kendo.template ($ ("\\ # check-results-template"). html ())

so just watch the "#" wherever you use kendo stuff !!

+2
source

You have 2 errors in your code:

  • you need to make your template from html script element
  • you need to call kendo.template(...) directly since this is a function, not between quotes.

This gives the following code:

 "template": kendo.template($("#someTemplate").html()) 

See this jsfiddle: http://jsfiddle.net/bSGdW/9/

+7
source

Source: https://habr.com/ru/post/1484152/


All Articles