0

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,
               }
                ],
            },



Objective-C Random Number

I have one piece of code that is giving me some trouble and is confusing.

Here is the piece of code...

int r = rand() % 100;
printf("Random number: %u", r);

Why does it print 7 every time? According to the book it should print any number 0-100 I believe... am I wrong with this?

4

1 回答 1

1

无论您在哪里创建视图,您都可以在此之前创建存储并将存储显式设置为视图,以便在执行初始化函数时它会得到this.config.store. 要在应用程序初始化时获取 GPS 位置,您Ext.application甚至可以在创建商店和视图之前在 Launch 函数中获取位置。如果您只想在商店数据加载后创建视图,您应该在商店的加载回调中创建视图。

我希望这是您正在寻找的东西,如果不是,请在您的问题中添加一些代码,以便我们可以对细节发表评论。

于 2013-05-17T05:58:51.957 回答