Results 1 to 4 of 4

Thread: [ PR4 ] What's wrong with my store ?

  1. #1
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    122
    Answers
    2
    Vote Rating
    67
      0  

    Default Answered: [ PR4 ] What's wrong with my store ?

    Hi all,

    I have tried many times and solutions for this but I've always encountered the same issue : "Uncaught TypeError: Object [object Object] has no method 'getRoot" while "Ext.define.updateStore" is executed in all-debug.js

    I have attached the zip wtih all files and I've copy paste all my code here. If someone has an idea or could test it, it will really be nice. I'm trying for hours now and gonna be mad

    index.html
    HTML Code:
    <!DOCTYPE html>
    <html>
        <head>
            <title>Getting Started</title>
            <link rel="stylesheet" href="../resources/css/sencha-touch.css" type="text/css">
            <script type="text/javascript" src="../sencha-touch-all-debug.js"></script>
            <script type="text/javascript" src="app.js"></script>
        </head>
        <body>
            <!-- hack so window opening works on all devices: http://www.sencha.com/forum/showthread.php?130358-window.open()-from-toolbar-button-opens-window-from-list-item-a-new-tab&p=639938#post639938 -->
            <a href="" target="_blank" id="linker" style="display:none;"></a>
        </body>
    </html>

    app.js
    Code:
    Ext.Loader.setConfig({ enabled: true });
    
    //Ext.Loader.setPath('Ext.data.proxy.Kiva', 'lib/KivaProxy.js');');
    //Ext.ClassManager.setAlias('Ext.data.proxy.Kiva', 'proxy.kiva');
    
    Ext.application({
        name        : 'Webshop',
        models      : ['Category'],
        views       : ['Main'],
        stores      : ['Categories'],
        controllers : ['Main'],
    
        launch: function() {
            Ext.create('Webshop.view.Main');
        }
    });

    app/controller/Main.js
    Code:
    // Ext.Webshop.Catalog controller
    Ext.define('Webshop.controller.Main', {
        extend: 'Ext.app.Controller',
    
        requires: [
            'Webshop.model.Category',
            'Webshop.store.Categories',
            'Webshop.view.Main'
        ],
    
        stores: ['Categories'],
    
        models: ['Category'],
    
        views: [
            'Main'
        ],
    
        init: function() {
            this.view = this.getMainView().create();
    
            this.categoriesStore = this.getCategoriesStore();
            this.categoriesStore.load({
                callback: this.onCategoriesLoad,
                scope: this
            });
    
            this.callParent(arguments);
        },
    
        onCategoriesLoad: function() {
            this.view.setStore(this.categoriesStore);
        }
    });

    app/view/Main.js
    Code:
    Ext.define('Webshop.view.Main', {
        extend: 'Ext.NestedList',
    
        config : {
            layout:'fit',
            fullscreen: true,
            displayField: 'text',
            store: null,
            title: 'Catalogue'
        }
    });

    app/store/Categories.js
    Code:
    Ext.define('Webshop.store.Categories', {
        extend: 'Ext.data.Store',
        requires: 'Webshop.model.Category',
        config: {
            model: 'Webshop.model.Category',
            autoLoad: false
        },
        root: {}
    });

    app/model/Category.js
    Code:
    Ext.define('Webshop.model.Category', {
        extend: 'Ext.data.Model',
        config: {
            fields: ['iItemId', 'text' ],
            proxy: {
                type: 'ajax',
                url: 'catalogcategory.json',
                reader: {
                    type: 'json',
                    rootProperty: 'items'
                }
            }
        }
    });

    catalogcategory.json
    Code:
    {
        "items": [
           {
               "iItemId": 1,
               "text": "Plomberie",
               "image": "plomberie-little.png",
               "items" : [
                    {
                        "iItemId": 11,
                        "text": "Plomberie > Outillage",
                        "image": "outillage-little.png",
                        "items" : [{
                                    "iItemId": 111,
                                    "text": "Plomberie > Outillage",
                                    "image": "outillage-little.png",
                                    "leaf": true
                        },
                        {
                                    "iItemId": 112,
                                    "text": "Plomberie > Outillage",
                                    "image": "outillage-little.png",
                                    "leaf": true
                        }],
                    },
                    {
                        "iItemId": 12,
                        "text": "Plomberie > Sanitaire",
                        "image": "outillage-little.png",
                        "items" : [{
                                    "iItemId": 121,
                                    "text": "Plomberie > Outillage",
                                    "image": "outillage-little.png",
                                    "leaf": true
                        },
                        {
                                    "iItemId": 122,
                                    "text": "Plomberie > Outillage",
                                    "image": "outillage-little.png",
                                    "leaf": true
                        }]
                    }]
           },
           {
               "iItemId": 2,
               "text": "Outillage",
               "image": "outillage-little.png",
                                    "leaf": true
           },
           {
               "iItemId": 3,
               "text": "Sanitaire",
               "image": "sanitaire-little.png",
                                    "leaf": true
           },
           {
               "iItemId": 4,
               "text": "Confort thermique",
               "image": "thermique-little.png",
                                    "leaf": true
           }
        ]
    }
    Archive.zip

  2. You should use TreeStore when using NestedList, not a regular Store.

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You should use TreeStore when using NestedList, not a regular Store.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    122
    Answers
    2
    Vote Rating
    67
      0  

    Default

    Thanks !
    I am just the stupiest guy on earth.

    i have others trouble with 'has no method 'animation'" but I will find.

  5. #4
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    122
    Answers
    2
    Vote Rating
    67
      0  

    Default

    OK, the animation error came from layout: "fit" that was not permitted here. I've deletd the line and it works great. Thanks.

Posting Permissions

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