Threaded View

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

      0  

    Default Answered: Button + Ext.List + Ext.navigation.View + Panel = I need some help

    Answered: Button + Ext.List + Ext.navigation.View + Panel = I need some help


    Hello!

    Kategori.png

    First, I have a button with an ID that is linked to a view that lists the data from JSON (see code below):

    Code:
    Ext.define('LG.view.categories', {
        extend: 'Ext.List',
        xtype: 'categories',
    
    
        requires: [
            'Ext.dataview.List',
            'Ext.data.proxy.JsonP',
            'Ext.data.Store'
        ],
        
        config: {
            title: 'Kategorier',
            cls: 'categories',
            indexBar: true,
            itemTpl: '<h2 class="YrkesBenamning">{YrkesBenamning}</h2>',
            onItemDisclosure: true,
            
            store: {
                autoLoad: true,
                fields: ['YrkesId', 'YrkesBenamning', 'antal'],
                
                grouper: {
                    groupFn: function(record) {
                        return record.get('YrkesBenamning')[0];
                    }
                },
    
    
                proxy: {
                    type: 'jsonp',
                    url: 'http://api.xxx.se/API.mvc/GetLillaGulaYrken?apikey=XXX',
                    reader: {
                        type: 'json',
                        rootProperty: 'responseData.feed.entries'
                    }
                }
            }
        }
    });
    Kategorilista.png

    When you click on an item to activate the function in my controller, see code below:

    Code:
        showCompany: function(list, index, element, record) {
            var YrkesId = record.get('YrkesId');
            console.log('id:' + YrkesId);
    /*
    *
    * Here I want to send the ID number to the next view, how do I do that?
    *
    */
    
            var companylistView = new Ext.create('LG.view.companylist');
            companylistView.setRecord(YrkesId);
            Ext.Viewport.setActiveItem(companylistView);
        }
    KategoriVald.png

    In this function I create also a new view called 'companlistView' and contains the following code below. Right now I manually added an ID number (10) for the JSON stream, such as: http://api.xxx.se/API.mvc/GetLillaGulaKunderByYrkeId/10?apikey=xxx
    But I need to get the ID number automatically for each item when you select a category, how do I do that? Do you understand what I mean?

    Code:
    Ext.define('LG.view.companylist', {
        extend: 'Ext.navigation.View',
        xtype: 'companylist',
        id: 'companyList',
    
    
        requires: [
            'Ext.dataview.List',
            'Ext.data.proxy.JsonP',
            'Ext.data.Store'
        ],
        
        config: {
            title: 'Sökresultat',
            cls: 'companylist',
    
    
            items: {
                xtype: 'list',
                //itemTpl: '<h2 class="KNamn">{KNamn}</h2><p class="KAdress"><a href="http://maps.apple.com/?q={KAdress}, {KPostNr} {KOrt}">{KAdress}<br>{KPostNr} {KOrt}</a></p>',
                itemTpl: '<h2 class="KNamn">{KNamn}</h2>',
                onItemDisclosure: true,
                title: 'S&ouml;kresultat',
                cls: 'categorylist',
                
                store: {
                    autoLoad: true,
                    fields: ['PhoneNumber', 'KNamn', 'KId', 'KAdress', 'KOrt', 'KPostNr'],
    
    
                    proxy: {
                        type: 'jsonp',
                        url: 'http://api.xxx.se/API.mvc/GetLillaGulaKunderByYrkeId/10?apikey=xxx',
                        reader: {
                            type: 'json',
                            rootProperty: 'responseData.feed.entries'
                        }
                    }
                }
            }
        }
    });
    Foeretag.png

    The last view is printed by means of a push (). Code below:

    Code:
        showCompanyDetails: function(list, index, element, record) {
            this.getCompanylist().push({
                xtype: 'panel',
                title: record.get('KNamn'),
                html: '<p style="border:solid 1px red;"><a href="tel:' + record.get('PhoneNumber') + '">' + record.get('KNamn') + '<br>' + record.get('PhoneNumber') + '</a><p><p style="border:solid 1px green;"><a href="rmaps:ll=63.288303,18.70905">' + record.get('KAdress') + '<br>' + record.get('KPostNr') + ' ' + record.get('KOrt') + '</a><p>',
                scrollable: true,
                styleHtmlContent: true
            });
        }
    Please help me!

  2. First, instead of this:

    Code:
            var companylistView = new Ext.create('LG.view.companylist');
            companylistView.setRecord(YrkesId);
    I would do this:

    Code:
            var companylistView = Ext.create('LG.view.companylist', { //notice no new!
                record : record
            });
    Then in the LG.view.companylist component you have access to the record (will get the id in a second). This means that you can now take action on that using the updateRecord...

    Code:
    Ext.define('LG.view.companylist', {
        extend: 'Ext.navigation.View',
        xtype: 'companylist',
    
        requires: [
            'Ext.dataview.List',
            'Ext.data.proxy.JsonP',
            'Ext.data.Store'
        ],
        
        config: {
            title: 'Sökresultat',
            cls: 'companylist',
    
            apiKey : 'xxxx',
    
            items: {
                xtype: 'list',
                //itemTpl: '<h2 class="KNamn">{KNamn}</h2><p class="KAdress"><a href="http://maps.apple.com/?q={KAdress}, {KPostNr} {KOrt}">{KAdress}<br>{KPostNr} {KOrt}</a></p>',
                itemTpl: '<h2 class="KNamn">{KNamn}</h2>',
                onItemDisclosure: true,
                title: 'S&ouml;kresultat',
                cls: 'categorylist',
                
                store: {
                    fields: ['PhoneNumber', 'KNamn', 'KId', 'KAdress', 'KOrt', 'KPostNr'],
                    proxy: {
                        type: 'jsonp',
                        reader: {
                            type: 'json',
                            rootProperty: 'responseData.feed.entries'
                        }
                    }
                }
            }
        },
    
        updateRecord : function(record) {
            var YrkesId = record.get('YrkesId'),
                list = this.down('list'),
                store = list.getStore(),
                proxy = store.getProxy() 
                apiKey = this.getApiKey();
    
            proxy.setUrl('http://api.xxx.se/API.mvc/GetLillaGulaKunderByYrkeId/' + YrkesId + '?apikey=' + apiKey);
    
            store.load();
        }
    });
    So the changes I made here is removed autoLoad from the store so we can handle loading, removed the url config from the proxy, added the updateRecord method to handle the record config or if you do a setRecord on this method. Now your store should load with the id in the URL. I also added a new config for apiKey to make it a little more elegant.

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