Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI Grid - How to declaratively set MVVM data column template to external template?

Tags:

kendo-ui

I am struggling with declarative setting grid column to a external template

Here's my template

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

and here's the grid declaration

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

And here's JS Fiddle reproducing my problem: JSFiddle repro

like image 833
Nikola Malovic Avatar asked Jan 13 '23 05:01

Nikola Malovic


1 Answers

You have 2 mistakes in your code :

  1. you have to make your template from the html of the script element
  2. you have to call directly kendo.template(...) as it is a function and not between quotes.

This gives such code :

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

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

like image 87
Samuel Caillerie Avatar answered May 01 '23 15:05

Samuel Caillerie