1. #1
    Sencha User sandrosss's Avatar
    Join Date
    Mar 2012
    Location
    Salvador-BA, Brazil
    Posts
    4
    Vote Rating
    0
    sandrosss is on a distinguished road

      0  

    Default Answered: itemTpl Ext.List don't get value of array field in model

    Answered: itemTpl Ext.List don't get value of array field in model


    Hello everyone,
    I'm having trouble with a field type array of my model.
    I can't get your value from "itemTpl" in the view (xtype: 'list').


    I can display other fields in itemTpl (object, string, int), but I can not display an array type.
    It is an application that retrieves results from Foursquare.


    My Store:


    Code:
    Ext.define('MyApp.store.Locations', {
    
    
        extend: 'Ext.data.Store',
        config: {
    
    
            model: 'MyApp.model.Locations',
            autoLoad: true,
            proxy: {
    
    
                type: 'jsonp',
                url: 'https://api.foursquare.com/v2/venues/search?',
                extraParams: {
                    client_id: 'My_ID',
                    client_secret: 'MY_SECRET',
                    intention: 'checkin',
                    ll: '-12.575499,-38.008066',
                    radius: '300',
                    limit: '30',
                    v: '20130325'
                },
    
    
                reader: {
                    type: 'json',
                    rootProperty: 'response.venues'
                }
            }
        }
    });

    My Model:
    Code:
    Ext.define('MyApp.model.Locations', {
    
    
        extend: 'Ext.data.Model',
        config: {
    
    
            fields: [
                {name: 'name',  type: 'string'},
                {name: 'contact', type: 'object'},
                {name: 'location', type: 'object'},
                {name: 'categories', type: 'array'}
            ]
        }
    
    
    });

    My View:
    Code:
    Ext.define('MyApp.view.Locations', {
    
    
        extend: 'Ext.navigation.View',
        xtype: 'locationscard',
        config: {
    
    
            iconCls: 'locate',
            items: [{
    
    
                title: 'locate',
                xtype: 'list',
                store: 'Locations',
                itemTpl: "<img src='{categories[0].icon.prefix}bg_64{categories[0].icon.suffix}'/> {name} - {location.distance}m",
    
    
                listeners: {
    
    
                    itemtap: function(list, index, item, record) {
    
    
                        var name = record.get('name'), pos = record.get("location"), cat = record.get("categories");
    
    
                        this.up('locationscard').push({
    
    
                            xtype   : 'panel',
                            title   : name,
                            html    : name
                                    + " " + pos.distance + "m"
                                    + " " + pos.lat
                                    + " " + pos.lng
                                    + " " + pos.address
                                    + " " + pos.city
                                    + " " + pos.state
                                    + "<img src='" + cat[0].icon.prefix + "bg_64" + cat[0].icon.suffix + "'/> "
                            ,
                            scrollable      : true,
                            styleHtmlContent: true
                        });
                    }
                }
            }]
        }
    
    
    });

    JSON response from Foursquare. I can't take the value of "categories" - categories[0].icon.prefix

    response:
    {
    • venues:
      [

      • {
        • id: "4ca618d4d971b1f755bcfce0",
        • name: "Aeroporto de Fernando de Noronha (FEN)",
        • contact:
          {
          • phone: "+558136191148",
          • formattedPhone: "+55 81 3619-1148"
          },
        • location:
          {
          • address: "Vila do DEPV",
          • lat: -3.8564173819886944,
          • lng: -32.4284235074893,
          • distance: 269,
          • city: "Fernando de Noronha",
          • state: "PE",
          • country: "Brazil",
          • cc: "BR"
          },
        • canonicalUrl: "https://foursquare.com/v/aeroporto-d...71b1f755bcfce0",
        • categories:
          [],
        • verified: false,
        • restricted: true,

    Has anyone experienced something similar?

  2. Can you try with:
    Code:
    {[values.categories[0].icon.prefix]}
    Let us know how it went

  3. #2
    grgur's Avatar
    Join Date
    Aug 2007
    Location
    Split, Croatia
    Posts
    155
    Answers
    10
    Vote Rating
    24
    grgur has a spectacular aura about grgur has a spectacular aura about

      1  

    Default


    Can you try with:
    Code:
    {[values.categories[0].icon.prefix]}
    Let us know how it went
    Grgur Grisogono
    Ext JS in Action SE co-author
    Exercising awesomeness at Modus Create - Official Sencha Partner

    Get in touch for Sencha Touch Training
    @ggrgur

  4. #3
    Sencha User sandrosss's Avatar
    Join Date
    Mar 2012
    Location
    Salvador-BA, Brazil
    Posts
    4
    Vote Rating
    0
    sandrosss is on a distinguished road

      0  

    Default


    Quote Originally Posted by grgur View Post
    Can you try with:

    Code:
    {[values.categories[0].icon.prefix]}
    Let us know how it went
    Thanks very much Grgur! Works fine!!!

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