1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    New Jersey
    Posts
    116
    Answers
    6
    Vote Rating
    5
    Mike6679 is on a distinguished road

      0  

    Default Unanswered: Add items in Abstract base class and child class

    Unanswered: Add items in Abstract base class and child class


    I have a base class where I have an item in my config. I aslo have a class that extends off this base class where I want to add additional items. It seems my child class is overriding my item in my base class. How can I get both to exist?

    Code:
    /* 
     * 
     * Abstract Class for all slides (Page_x_x_x)
     * 
     */
    Ext.define('epiduo_ped.view.Page',
    {
        extend:  'Ext.Panel', 
        
        //xtype:   'page',
        //fullscreen: true,
        
        config:
        {
            
            items:[
                {
                    
                    xtype:'pleasesee'
                }
            ]
        }
    	
        ,
        initialize: function(){      
           me = this; 
        }
    });
    child class:

    Code:
    Ext.define('epiduo_ped.view.1-1-1.Page_1-1-1',
    {
        extend:  'epiduo_ped.view.Page',  
        xtype:   'page1-1-1',
       
        config:
        {
           cls:"page1_1_1BG",
           items:[ 
          
            {  
               xtype:'hotspot',
               width:320,
               height:400,
               top:200,
               left:170,
               id: 'hotspot_page1-1-1_a'
            },
            {  
               xtype:'hotspot',
               width:320,
    		   height:400,
    		   top:200,
    		   left:533,
               id: 'hotspot_page1-1-1_b'
            }
           ]
           
        }
    });

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


    First off people really need to stop doing this:

    Code:
        initialize: function(){      
           me = this; 
        }
    You aren't doing anything in there so don't have it. If you are going to do something then you need to have this.callParent(); in there so it will call it's superclass' initialize method.

    You are overriding the items and there isn't an easy way to do it. You could use the applyItems method to insert an item (don't forget the callParent call). You can use the onClassExtended method to change the items array.
    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.

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
    nhan is on a distinguished road

      0  

    Default


    Hi mitchellsimoens,

    ApplyItems will override all the items in the base class. How can I add some items in subclass to one of containers in the superclass? (I only want to plug the items into a place holder in the base class). So there will be multiple subclasses showing different pages.
    thanks for any suggestion or advice or comment

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    851
    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


    You always have access to the superclass with using callParent.
    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.

  5. #5
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
    nhan is on a distinguished road

      0  

    Default


    I do call callParent(args) in initComponent(). Can you give a short example on how to add items in subclass?

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    851
    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


    Sencha Touch doesn't use initComponent (it's been deprecated and you should get a warning in the console).

    Code:
    applyItems: function(newItems, oldItems) {
        //can do anything here to newItems, oldItems doesn't do anything currently
    
        return this.callParent([newItems, oldItems]);
    }
    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.

  7. #7
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
    nhan is on a distinguished road

      0  

    Default


    I am in extjs 4 not sencha tough

  8. #8
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
    nhan is on a distinguished road

      0  

    Default


    Not Sencha Touch

Thread Participants: 2

Tags for this Thread