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

how to make my template works properly

1 Answer 63 Views
Templates
This is a migrated thread and some comments may be shown as answers.
guillaume
Top achievements
Rank 1
guillaume asked on 14 Nov 2013, 12:53 PM
Hello !

i'm currently trying to use the template system with data binding from a json local file but i've got a preblem to make it work.

here is my json code which is into a data.json local file:

[
{ "Nom": "Test", "Pays": "FR", "Adresse1": "Rue du test", "CP": "59000" }
]
here is my javascript code

var dataSource = new kendo.data.DataSource({
    transport: {
        read: {
            url: "./data.json",
            dataType: "json"
        },
    }
});
 
$("#PointRelaisList").kendoMobileListView({
    dataSource: dataSource,
    template: $("#PointRelaisListTemplate").text()
});
here is my template

<script id="PointRelaisListTemplate" type="text/x-kendo-template">   
<span class="PointRelaisImage" style="background-image: url('http://www.mondialrelay.fr/img/dynamique/pr.aspx?id=#: Pays ##: kendo.toString(ID, '0000000') #')" ></span>
<div class="PR-Name">
#: Nom #
<span class="value">(0.2 km)
<a class="button" data-role="button" href="\#DetailPointRelais?Id=#: Pays ##: kendo.toString(ID, '0000000') #&Nom=#: Nom #" data-icon="info" style="font-size:10px;background-color:\#7184a2"></a>
<a class="button" data-role="button" data-context="#:ID#" data-click="setFavorite" data-icon="toprated" style="font-size:10px;background-color:\#7184a2"></a>
</span>
</div>
<div class="PR-Adress"> #: Adresse1 #
<br/> #: Pays # - #: CP #  #: Ville #
</div>
</script>
and here is the div where the html is added:

<div data-role="scroller" class="scroller-content" >
  <ul data-role="listview" data-style="inset" class="MRW-Results" id="PointRelaisList" data-template="PointRelaisListTemplate">
  </ul>
</div>
if someone could help me out to solve that problem ... ;)

thanks you ! :)

1 Answer, 1 is accepted

Sort by
0
guillaume
Top achievements
Rank 1
answered on 14 Nov 2013, 01:11 PM
The format of my json file was just wrong ;)
Tags
Templates
Asked by
guillaume
Top achievements
Rank 1
Answers by
guillaume
Top achievements
Rank 1
Share this question
or