This is a migrated thread and some comments may be shown as answers.

Call kendo.template from data-template on <th>

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 13 Mar 2015, 06:59 PM
I am generating a grid from a rendered table and need to be able to set the template as a function returned from kendo.template:

<th data-template="#: kendo.template($('\\#datePaymentEligible-template').html()) #">Payment Elig.</th>

Unfortunately, this results in displaying the following in each cell of the rendered grid:

function anonymous(data /**/) { var o,e=kendo.htmlEncode;with(data){o='\n '+( datePaymentEligible != null ? kendo.toString(datePaymentEligible, 'd') : '' )+'\n ';}return o; }

My template definition looks like this:

<script id="datePaymentEligible-template" type="text/x-kendo-template">
    #= datePaymentEligible != null ? kendo.toString(datePaymentEligible, 'd') : '' #
</script>

I originally had this inline and it was working. But I've broken it out as a separate template because I intend to expand on it further.

Any help?

Thanks,
Gary

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Mar 2015, 02:10 PM
Hello Gary,

The template method will just compile a template from the passed string. You should execute the compiled template in order to get the expected result:
<th data-template="#: kendo.template($('\\#datePaymentEligible-template').html())(data) #">Payment Elig.</th>

You might also consider compiling the template only once before initializing the grid:
window.datePaymentEligibleTemplate = kendo.template($('#datePaymentEligible-template').html());
<th data-template="#: datePaymentEligibleTemplate(data) #">Payment Elig.</th>


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Gary
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or