1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    10
    Vote Rating
    0
    pdiddy26 is on a distinguished road

      0  

    Default Answered: Simple MVC list not working

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,672
    Answers
    3354
    Vote Rating
    747
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


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

    Code:
    this.callParent(arguments);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar