1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    9
    Vote Rating
    0
    puttan is on a distinguished road

      0  

    Default Answered: List Reader JsonView

    Answered: List Reader JsonView


    Hello, Sencha People!

    I need some help with a list that reads a JSON call, and the call looks like below:

    Code:
    "Restaurants": [{
            "Name": "B-O:s Restaurang",
            "Lunches": [{
                "Course": "Köttbullar stuvade grönsaker"
            }, {
                "Course": "Stekt Kycklingfilé svampsås"
            }, {
                "Course": "Räksallad"
            }, {
                "Course": "Sparrissoppa"
            }, {
                "Course": "Vegetarisk Quorngryta"
            }],
            "MapUrl": "http://maps.google.se/maps?f=q&hl=sv&geocode=&q=Björnavägen+41%2cÖrnsköldsvik",
            "TelUrl": "tel:066080650"
        },
    ...
    My code follows:
    Code:
    var date = new Date();
    var currentYear = Ext.Date.format(date, 'Y');
    var currentMonth = Ext.Date.format(date, 'j');
    var currentDay = Ext.Date.format(date, 'd');
    
    
    Ext.define('LG.view.Lunch', {
        extend: 'Ext.navigation.View',
        xtype: 'lunch',
    
    
        requires: [
            'Ext.dataview.List',
            'Ext.data.proxy.JsonP',
            'Ext.data.Store',
            'Ext.DateExtras'
        ],
        
        config: {
            title: 'Lunch',
            iconCls: 'home',
            cls: 'lunch',
            
            items: {
                xtype: 'list',
                itemTpl: '<h2 class="Name">{Name}</h2><p class="Lunches">{Lunches}</p>',
                title: 'Dagens lunch',
                
                store: {
                    autoLoad: true,
                    fields: ['Name', 'Lunches'],
                    
                    proxy: {
                        type: 'jsonp',
                        url: 'http://api.lillagula.se/API.mvc/GetW7Lunches?year=' + currentYear + '?month=' + currentMonth + '?day=' + currentDay + '&apikey=f87c21f3-3c14-4661-9c9a-add5d7c7988c',
                        reader: {
                            type: 'json',
                            rootProperty: 'Restaurants'
                        }
                    }
                }
            }
        }
    });
    And my result, according to the screenshot:

    Dump.jpg

    How do I to print the so-called "Course" (objects)?

    Please, help me! I am a newbie, but I like Sencha Touch 2.

    /Patrik

  2. Check out documentation for XTemplate . Instead of

    Code:
    <p class="Lunches">{Lunches}</p>
    you can try

    Code:
    <p class="Lunches">
    <tpl for="Lunches">{Course}</tpl>
    </p>
    to iterate over Lunches array.

  3. #2
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Answers
    4
    Vote Rating
    5
    szimek is on a distinguished road

      0  

    Default


    Check out documentation for XTemplate . Instead of

    Code:
    <p class="Lunches">{Lunches}</p>
    you can try

    Code:
    <p class="Lunches">
    <tpl for="Lunches">{Course}</tpl>
    </p>
    to iterate over Lunches array.

  4. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    9
    Vote Rating
    0
    puttan is on a distinguished road

      0  

    Default


    Thank you very much for your helping hand.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi