Results 1 to 2 of 2

Thread: Simple MVC list not working

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    10
    Vote Rating
    0
      0  

    Default Answered: Simple MVC list not working

    Hi,

    I'm trying to write my first simple mvc app. I have a Main View and a Products view. I also have a Main controller. My Products view extend Ext.List. My problem is the list doesn't show anything even though I've set the data and itemTpl. Here is my code:

    app.js
    Code:
    Ext.application({
        name: 'SenchaTest',
    
    
        controllers: ['Main'],
    
    
        launch: function() {
            // Destroy the #appLoadingIndicator element
            Ext.fly('appLoadingIndicator').destroy();
            
            Ext.create('SenchaTest.view.Main');
        },
    });
    view/Main.js
    Code:
    Ext.define('SenchaTest.view.Main', {
        extend: 'Ext.TabPanel',
        requires:['Ext.data.Store'],
        
        config: {
            fullscreen: true,
            items:[
                {
                    xtype:'productspage',
                    title:'Products',
                    data: [
                            { title: 'Item 1' },
                            { title: 'Item 2' },
                            { title: 'Item 3' },
                            { title: 'Item 4' }
                    ],
                    itemTpl:'{title}'
                }
            ]
        },
        
        initialize: function() {
            console.log('Main view initialize');
        }
        
    });

    view/Products.js
    Code:
    Ext.define('SenchaTest.view.Products', {
        extend: 'Ext.List',
        xtype: 'productspage',
        
        initialize: function() {
            console.log('Products view initialize');
        },
        
    });
    controller/Main.js
    Code:
    Ext.define('SenchaTest.controller.Main',{
        extend: 'Ext.app.Controller',
        config:{
            views:['Main', 'Products'],
        },
        
        launch: function() {
            console.log('Main Controller launch');
        },
        
        init: function() {
            console.log('Main Controller init');
        }
    });

    Here is what appears in my console:
    Main Controller init
    Products view initialize
    Main view initialize
    Main Controller launch

    So my views and controller are initiated. But nothing shows in my products list. The list component does seem to have been loaded because i can see scrollbars when dragging it.

    The weird thing is if I change the xtype: 'productspage' to xtype:'list' .... it works .... but my products view extend Ext.List ... so isn't it the same?

  2. When you override the initialize method, you need to execute callParent

    Code:
    this.callParent(arguments);

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

    Default

    When you override the initialize method, you need to execute callParent

    Code:
    this.callParent(arguments);
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

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

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

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