0
votes

I'm trying to get Store in the view on the init of the applicatoin, however the console tells me: Object #<Object> has no method 'getStore'

I'm wondering how would you get a store in this sequence:

  1. Initialise app
  2. Get user GPS location
  3. Create a store
  4. Display view with the store
    init: function () { 
        this.callParent();
        console.log("controller init");
    },
    launch: function () {
        this.getApplicationSettings();
        this.getApplicationRegionalisation();
        Ext.getStore("appSettings").setValue("region", "Melbourne");

        var store = Ext.create("APN.store.Locations");
        var geo = Ext.create('Ext.util.Geolocation', {
            autoUpdate: false,
            listeners: {
                locationupdate: function(geo) {
                    var location = store.getClosestLocation(geo.getLatitude(), geo.getLongitude());
                    Ext.getStore("appSettings").setValue("region", location.get("location"));
                },
                locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
                }
            }
        });

And then in the view I would like to call something like this, correct me if I'm doing a stupid thing:

    requires: [
        'APN.store.AppSettings'
    ],
..... omitted stuff

// in items:
        items: [
            {
                itemId: 'nav_home',
        id: 'homeView',
                group: '',
                title: "Home",
                layout: 'vbox',
                slideButton: { selector: 'toolbar' },
                settingsButton: { selector: 'toolbar' },
                items: [{
                   xtype: 'articlelist',
                   id: 'latestNews',
                   category: 'Latest',
                   feedUrlName: 
// here is the place where it bugs out!
Ext.getStore("appSettings").getValue(Ext.getStore("appSettings").getValue("region").get("menuItems").home.url,
               }
                ],
            },


1
at which line you are getting errors?ThinkFloyd
where the it says // here is the place where it bugs out So my understanding when the application loads all files and compiles interprets them and sees that Ext.Store is not initialized, then it loads controller init method and controller launch method where the store is initializedJackie Chan

1 Answers

1
votes

Wherever you are creating the view, you can create the store before that and set store to the view explicitly so that when initialize function is executed it will get this.config.store. To get GPS location on app initialization, you can get location in Launch function of Ext.application before even creating the store and view. If you want to create view only after store data is loaded, you should create view in load callback of store.

I hope this is what you were looking for, if not please add some code to your question so that we can comment on specifics.