how to make my template works properly

2 posts, 1 answers
  1. Answer
    guillaume
    guillaume avatar
    7 posts
    Member since:
    Oct 2013

    Posted 14 Nov 2013 Link to this post

    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 ! :)
  2. guillaume
    guillaume avatar
    7 posts
    Member since:
    Oct 2013

    Posted 14 Nov 2013 Link to this post

    The format of my json file was just wrong ;)
  3. Kendo UI is VS 2017 Ready
Back to Top