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

ClientRowTemplate with external template

5 Answers 370 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan Mosley
Top achievements
Rank 1
Alan Mosley asked on 23 Jul 2015, 05:45 PM

I want to use ClientRowTemplate with external template but cant seem to reference it

.ClientRowTemplate(  what goes here   ) 

how to do . thanks

<script id="cart-grid-template" type="text/x-kendo-template">
...
</script>

5 Answers, 1 is accepted

Sort by
0
eo
Top achievements
Rank 1
answered on 24 Jul 2015, 02:46 PM

Hello Alan,

To reference an external template you need to use its id like this:

var externalTemplateContent = $("#cart-grid-template").html();​

After that you should be able to call .clientRowTemplate(externalTemplateContent)

0
Alan Mosley
Top achievements
Rank 1
answered on 24 Jul 2015, 02:50 PM
I did see that and tried it, I ended up doing something else, but will try your solution again next time, thanks
0
eo
Top achievements
Rank 1
answered on 24 Jul 2015, 02:54 PM

Glad you solved it already, could you share the solution that worked for you?

Thanks

0
Alan Mosley
Top achievements
Rank 1
answered on 25 Jul 2015, 12:18 AM
I was converting a site from the old mvc wrappers to Kendo and had trouble with one grid with heaps of inline template hard to maintain, in the end I used listview, it has all I need to replace the grid and has ClientTemplateId,  Thanks
0
Dimiter Madjarov
Telerik team
answered on 27 Jul 2015, 08:02 AM

Hello guys,

In order to use an external template as client or client row template, you could compile it via the kendo.template method.
E.g.

<script id="columnTemplate" type="text/x-kendo-template">
    ...
</script>
  
<script>
    var myTemplate = kendo.template($('#columnTemplate').html());
</script>

.ClientRowTemplate("#=myTemplate(data)#");

Regards,
Dimiter Madjarov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Alan Mosley
Top achievements
Rank 1
Answers by
eo
Top achievements
Rank 1
Alan Mosley
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or