1. #11
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,098
    Vote Rating
    113
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Quote Originally Posted by dboy221 View Post
    The Nav view has a container within it. Within that container, is where the link to the currentWeatherCTR is provided.
    I don't understand. You are instantiating an instance of it in the above code snippet. Do you then add it to a container? It's not going to show otherwise.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  2. #12
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    dboy221 is on a distinguished road

      0  

    Default


    I've provided a screen shot of my setup in architect...
    img.png

  3. #13
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,098
    Vote Rating
    113
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    I think I see where you are getting mixed up.
    Code:
    var currentWeatherCtr =  Ext.create('CatApp.view.ContainerCurrentWeather', { title: ''});
    The above code which you pasted is going to create a new instance of the class ContainerCurrentWeather. This is *different* than the instance which you've created in the MainPage and named 'containercurrentweather'.

    You creating a new instance of this class and then aren't doing anything with it, (adding it to a container, etc).

    Sounds like what you are probably intending to do is grab a reference to the instance of 'containercurrentweather' and setData on it. Make sense?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  4. #14
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    dboy221 is on a distinguished road

      0  

    Default


    I understand what your saying. I should get a reference to the alias of the container, containercurrentweather, instead of creating a new instance of the container. How do I go about making this reference (I'm assuming by creating it in the Controller of where this view is to be populated onActivate)? If this is correct, how do I make reference to it in the code? Sorry, for so many questions, but I am a newbie with Architect and Sencha.

  5. #15
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,098
    Vote Rating
    113
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    There are many ways to get a reference to it. Let's start off with:

    Give it an itemId and then retrieve it via componentquery, in the container that holds it you can then do this.down('#myItemId')

    Probably the easiest way but has a few drawbacks in scaling your application is to register it with a global id. If you register it with a global id, you can access it from anywhere in your code like so:
    Ext.getCmp('myGlobalId')

    The primary drawback to this is that you have to manage all of your id's (they are global and must be unique). itemId's on the other hand must be unique to their container.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  6. #16
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    dboy221 is on a distinguished road

      0  

    Default


    I was able to utilize the global approach to get the record. Thanks for all the help. One more requests of you...I promise

    I am attempting to load the json from the service call via the code below. In doing so I have set up the store and associated model (with only one field called 'temp_f'). I printed out the the first and only record of records and on the data object I get undefined for the temp_f. If you look at the json returned there is no root so I did not specify one.

    Code:
    var store = Ext.data.StoreManager.lookup('currentWeatherStore'),
        url = 'http://api.wunderground.com/api/3a1f...acramento.json';
    
    
        store.getProxy().setUrl(url);
        store.load({
            callback: function(records, success, operation){
                console.log(records[0]);
                
                var currentWeatherCtr =  Ext.getCmp('containerCurrentWeather', { title: ''}); 
                currentWeatherCtr.setData(records[0].data);
                
            }, scope: this
        });

  7. #17
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,098
    Vote Rating
    113
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    That link does not have any temp_f data in it... it looks like the root of teh records would be response.results.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  8. #18
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    dboy221 is on a distinguished road

      0  

    Default


    Actually there was typo in the link (sorry). The correct link is http://api.wunderground.com/api/3a1f...acramento.json, which you will see a "temp_f" field within the rendered json. If you see there is no root specified (at least from what I can tell). I was hoping that I could have some fresh eyes that could see if there is something missing from the implementation.

  9. #19
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,098
    Vote Rating
    113
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    It's in the current_observation object.

    If o is your decoded json you could access it like so o.current_observation.temp_f
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  10. #20
    Sencha User
    Join Date
    Jul 2012
    Posts
    38
    Vote Rating
    0
    dboy221 is on a distinguished road

      0  

    Default


    So i tried the recommended...

    Code:
    console.log(records[0].data.current_observation.temp_f);
    and got 'Uncaught TypeError: Cannot read property 'temp_f' of undefined'

    Here's the store setup...
    Code:
    Ext.define('CatApp.model.CurrentWeatherStore', {
        extend: 'Ext.data.Model',
        alias: 'model.currentweatherstore',
    
    
        config: {
            fields: [
                {
                    name: 'temp_f',
                    type: 'float'
                }
            ]
        }
    });

Thread Participants: 1