Results 1 to 3 of 3

Thread: Store undefined

  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    23

    Default Store undefined

    Hi I got this strange error when Sencha touch tries to build my Dataview.
    It throws the error "DataView requires tpl, store and itemSelector configurations to be defined."
    I already now this bug and mostly it's no problem for me to fix it.

    The special thing is I get this error only on real devices when I use my app inside phonegap. I tried my app hundred times in Google Chrome, Safari and even in the Iphone Simulator. But on my Iphone 4 with v5.1 and my Android Galaxy Nexus 2.3.5 it won't work and allways fails. When I'm removing this navigation point everything works smoth.
    The bug happens in the initcomponent function on 34432.

    I narrowed the bug down to the store.

    PHP Code:
    if (!isDef(this.tpl) || !isDef(this.store) || !isDef(this.itemSelector)) {
                throw 
    "DataView requires tpl, store and itemSelector configurations to be defined.";
     } 
    Just checked here what really is not defined with three ifs and it always tells me that the store is missing.

    This is the store:
    PHP Code:
    app.stores.TopLeaguesStore = new Ext.data.Store({
        
    model'topleagues',
        
    /**
         * check if store is already loaded
         * @return {Boolean} if store is loaded true
         */
        
    isLoaded: function() {
            return 
    this.loaded;
        },
        
    listeners: {
            
    /**
             * listener for the load event of a store
             * @param {Object} store
             */
            
    load: function(store) {
                
    store.loaded true;
            }
        }
    }); 
    And this the model:


    PHP Code:
    var dbconnval = {
        
    dbName"swissunihockey",
        
    dbDescription"swissunihockey_db",
    };
    Ext.DbConnection = new Ext.Sqlite.Connection(dbconnval);

    Ext.regModel('topleagues', {
        
    fields: [
            {
                
    name'id',
                
    type'int',
                
    fieldOption'NOT NULL PRIMARY KEY AUTOINCREMENT'
            
    }, {
                
    name'leaguecode',
                
    type'int',
                
    fieldOption'UNIQUE'
            
    }, {
                
    name'leaguetext',
                
    type'string'
            
    }, {
                
    name'wertungsmodus_id',
                
    type'string'
            
    }
        ],
        
    proxy: {
            
    type'sqlitestorage',
            
    dbConfig: {
                
    tablename'topleagues',
                
    dbConnExt.DbConnection.dbConn
            
    },
            
    reader: {
                
    idProperty'ID'
            
    }
        },
        
    writer: {
            
    type'json'
        
    }
    }); 

    Note: I'm using the sqliteproxy from tomalex but I'm using this plugin for months now and I don't think that it's a bug in the plugin.

    This is my view:
    PHP Code:
    app.views.TopLeaguesCard Ext.extend(Ext.Panel, {
        
    id'topLeaguesCard',
        
    layout'card',
        
    title'Obere Leagues',
        
    iconCls'leagues',
        
    listeners: {
            
    singletrue,
            
    activate: function() {
                if(
    app.handlers.Network.checkDevice()) {
                    
    app.utils.Helper.showMask();
                    
    app.handlers.NetRequest.topLeagues();
                } else {
                    
    app.utils.Helper.showMask();
                    
    app.stores.TopLeaguesStore.load({
                        
    callback: function (recordsoperationsuccess) {
                            
    app.utils.Helper.hideMask();
                        }
                    });
                }
            }
        },

        
    initComponent: function() {
            var 
    topLeaguestpl = new Ext.XTemplate(
                
    '<tpl for=".">',
                    
    '<div class="leaguetext">{[this.decodeContent(values.leaguetext)]}</div>',
                
    '</tpl>',
                {
                    
    decodeContent: function(content) {
                        return 
    unescape(content);
                    }
                }
            );

            
    this.topLeaguesList = new Ext.List({
                
    storeapp.stores.TopLeaguesStore,
                
    loadingText'',
                
    emptyText'<div class="emptymsg">Konnte keine Daten laden.' +
                    
    ' Bitte verbinden Sie sich mit dem Internet und benutzen Sie den Refresh-Button</div>',
                
    itemTpltopLeaguestpl,
                
    onItemDisclosuretrue,
                
    listeners: {
                    
    selectionchange: {fnthis.onSelectscopethis}
                }
            });

            
    this.topLeaguesPanel = new Ext.Panel({
                
    id'topLeaguesPanel',
                
    layout'fit',
                
    itemsthis.topLeaguesList,
                
    dockedItems: [{
                    
    xtype'toolbar',
                    
    title'Obere Leagues',
                    
    items: [
                        {
                            
    xtype'spacer'
                        
    }, {
                            
    id'topleaguesbtn',
                            
    iconCls'refresh',
                            
    iconMasktrue,
                            
    stretchfalse,
                            
    listeners: {
                                
    'tap': {
                                    
    fnapp.handlers.Refresh.refreshData,
                                    
    buffer500
                                
    }
                            }
                        }
                    ]
                }]
            });

            
    this.items this.topLeaguesPanel;
            
    app.views.TopLeaguesCard.superclass.initComponent.call(this);
        },
        
    onSelect: function(selrecords) {
            if (
    records[0] !== undefined) {
                var 
    detailCard = new app.views.TopGroupsView({
                    
    prevCardthis.topLeaguesPanel,
                    
    recordrecords[0]
                });
                
    this.setActiveItem(detailCard'slide');
            }
        }
    });
    Ext.reg('TopLeaguesCard'app.views.TopLeaguesCard); //set xtype to TopLeaguesCard 

    I really hope someone can help me. I'm trying for 4 hours here and just can't find my mistake :/

    Thanks for any help and have a nice day

    Eryx
    Last edited by eryx; 9 Feb 2012 at 12:24 PM. Reason: Forgot php tags

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450
    Answers
    3997

    Default

    The store is undefined in the topLeaguesList component?

    Check to see if the app.stores.TopLeaguesStore store is created at that point.

    Also, you shouldn't use listeners as a property when using Ext.extend
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    23

    Default Re

    Hi there thanks for your quick answer. You're right I really should have checked this first and I did now.
    In the browser the store is defined and as soon as it is compiled and on a real device the store is undefined at this moment. So I know now where the problem is but I'm not sure what I do wrong I never had the problem that a store was not ready.

    PHP Code:
    <!DOCTYPE html>
    <
    html><!--manifest="cache.manifest">-->
        <
    head>
            <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <
    title>Swiss Unihockey</title>
            <!-- 
    stylesheet -->
            <
    link href="resources/css/Application.css" rel="stylesheet" type="text/css" />
            <!-- 
    sencha touch -->
            <
    script src="resources/sencha-touch-debug-w-comments.js" type="text/javascript"></script>

            <!-- plugin sqlite -->
            <script src="plugins/override.js" type="text/javascript"></script>
            <script src="plugins/SqliteConnection.js" type="text/javascript"></script>
            <script src="plugins/SqliteProxy.js" type="text/javascript"></script>
            <script src="plugins/phonegap-1.3.0_iOS.js" type="text/javascript"></script>

            <!-- init -->
            <script src="app.js" type="text/javascript"></script>

            <!-- utils -->
            <script src="utils/helperclass.js" type="text/javascript"></script>

            <!-- handlers -->
            <script src="handlers/netrequesthandler.js" type="text/javascript"></script>
            <script src="handlers/networkhandler.js" type="text/javascript"></script>
            <script src="handlers/parsehandler.js" type="text/javascript"></script>
            <script src="handlers/refreshhandler.js" type="text/javascript"></script>
            <script src="handlers/sqlitehandler.js" type="text/javascript"></script>
            
            <!-- models -->
            <script src="models/topleagues_model.js" type="text/javascript"></script>
            <script src="models/otherleagues_model.js" type="text/javascript"></script>
            <script src="models/topgroups_model.js" type="text/javascript"></script>
            <script src="models/othergroups_model.js" type="text/javascript"></script>
            <script src="models/news_model.js" type="text/javascript"></script>
            <script src="models/toptable_model.js" type="text/javascript"></script>
            <script src="models/topgamesplayed_model.js" type="text/javascript"></script>
            <script src="models/topgamesplanned_model.js" type="text/javascript"></script>
            <script src="models/othertable_model.js" type="text/javascript"></script>
            <script src="models/othergamesplayed_model.js" type="text/javascript"></script>
            <script src="models/othergamesplanned_model.js" type="text/javascript"></script>

            <!-- stores -->
            <script src="stores/topleagues/topleagues_store.js" type="text/javascript"></script>
            <script src="stores/otherleagues/otherleagues_store.js" type="text/javascript"></script>
            <script src="stores/topgroups/topgroups_store.js" type="text/javascript"></script>
            <script src="stores/othergroups/othergroups_store.js" type="text/javascript"></script>
            <script src="stores/news/news_store.js" type="text/javascript"></script>
            <script src="stores/toptable/toptable_store.js" type="text/javascript"></script>
            <script src="stores/topgames/topgamesplayed_store.js" type="text/javascript"></script>
            <script src="stores/topgames/topgamesplanned_store.js" type="text/javascript"></script>
            <script src="stores/othertable/othertable_store.js" type="text/javascript"></script>
            <script src="stores/othergames/othergamesplayed_store.js" type="text/javascript"></script>
            <script src="stores/othergames/othergamesplanned_store.js" type="text/javascript"></script>

            <!-- viewport -->
            <script src="views/viewport.js" type="text/javascript"></script>

            <!-- views -->
            <script src="views/news/news_view.js" type="text/javascript"></script>
            <script src="views/topleagues/topleagues_view.js" type="text/javascript"></script>
            <script src="views/otherleagues/otherleagues_view.js" type="text/javascript"></script>

            <!-- detailviews -->
            <script src="views/news/news_detail.js" type="text/javascript"></script>
            <script src="views/topgroups/topgroups_view.js" type="text/javascript"></script>
            <script src="views/othergroups/othergroups_view.js" type="text/javascript"></script>
            <script src="views/topgroupdetail/topgroupdetail_view.js" type="text/javascript"></script>
            <script src="views/othergroupdetail/othergroupdetail_view.js" type="text/javascript"></script>

            </head>
        <body>
        </body>
    </html> 
    This is my index.html file and normaly this works just fine when I first use the model then the store and only then the view itself. Do you have any suggestions?

    Greetings eryx

    Edit: Ok I could fix the Problem. I moved store and model up right after the app.js and it looks like this works.

    Just one question please You said I should not use listeners as a property when using extend. I'm always eager to learn new things but I'm not sure how I would do else.

    Thanks for your help anyway!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •