1. #1
    Touch Premium Member
    Join Date
    Jan 2011
    Posts
    55
    Answers
    3
    Vote Rating
    1
    maddhippy is on a distinguished road

      0  

    Default Answered: Ext.create vs. xtype

    Answered: Ext.create vs. xtype


    I am trying to add a tab to a tabpanel.
    if I do:
    Code:
    myTabPanel.add({xtype:'tabclass-xtype'})
    it works.

    But
    Code:
    myTabPanel.add(Ext.create('tabClass'))
    does not.

    I want to use the class name because then I can loop through this.getViews() in the controller and add each view progromattically.

    Does anyone know why lazy instantiation via xtype works but not Ext.create to add to a tab? Or does anyone have any advice to be able to loop through view names and add them to a tabpanel?

    Thanks again

  2. This is working for me:

    Code:
    Ext.define('tabClass', {
        extend : 'Ext.Component',
        xtype  : 'tabclass-xtype',
    
        config : {
            title : 'Tab Class',
            html  : 'Do you see me?'
        }
    });
    
    var tabpanel = Ext.create('Ext.tab.Panel', {
        fullscreen : true,
        items      : [
            {
                title : 'One',
                html  : 'One'
            }
        ]
    });
    
    tabpanel.add(Ext.create('tabClass'));

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Answers
    3549
    Vote Rating
    849
    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


    This is working for me:

    Code:
    Ext.define('tabClass', {
        extend : 'Ext.Component',
        xtype  : 'tabclass-xtype',
    
        config : {
            title : 'Tab Class',
            html  : 'Do you see me?'
        }
    });
    
    var tabpanel = Ext.create('Ext.tab.Panel', {
        fullscreen : true,
        items      : [
            {
                title : 'One',
                html  : 'One'
            }
        ]
    });
    
    tabpanel.add(Ext.create('tabClass'));
    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.

  4. #3
    Touch Premium Member
    Join Date
    Jan 2011
    Posts
    55
    Answers
    3
    Vote Rating
    1
    maddhippy is on a distinguished road

      0  

    Default


    Yeah, it must be something in my tab. they are all lists or data views, which are more picky than most.

    I didn't realize I could create my own config object: tabs and keep the list of xtypes in them, which works perfectly

Thread Participants: 1