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

List Templates in external files

1 Answer 110 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 03 May 2012, 06:49 PM
I created a List that is populated from an external JSON file.

But I don't like cluttering my HTML with Javascript snippets, So I thought I could just reference an external file. But that is not working:

Original: (which works)

<div id="listView">
    <script src="Templates/TypeEntryTemplate.tmpl" type="text/x-kendo-tmpl" id="template" >
        <div class="typeEntry">
            <input id="typeCheck-${idx}" value="type-${type}" type="checkbox" checked="checked"/>
            <label for="typeCheck-${idx}">${type}</label>
        </div>
    </script>
</div>

Moving the script to an external file:

<div id="listView">
    <script src="Templates/TypeEntryTemplate.tmpl" type="text/x-kendo-tmpl" id="template" />
</div>

External File (Templates/TypeEntryTemplate.tmpl :

<div class="typeEntry">
    <input id="typeCheck-${idx}" value="type-${type}" type="checkbox" checked="checked"/>
    <label for="typeCheck-${idx}">${type}</label>
</div>


FYI: here is the code that creates the ListView:

$("#listView").kendoListView({
    dataSource:dataSource,
    pageable:false,
    template:kendo.template($("#template").html())
});

1 Answer, 1 is accepted

Sort by
0
Dr.YSG
Top achievements
Rank 2
answered on 04 May 2012, 04:23 PM
Overnight it occured to me that I was being stupid.

I now create the kendo template as a string and use Jquery.Extend  to clone the template and replace pieces. So I am closing this thread.

Tags
ListView
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Dr.YSG
Top achievements
Rank 2
Share this question
or