Results 1 to 8 of 8

Thread: Add items in Abstract base class and child class

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    New Jersey
    Posts
    116
    Answers
    6
    Vote Rating
    5
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,318
    Answers
    3883
    Vote Rating
    1292
      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 @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.

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,318
    Answers
    3883
    Vote Rating
    1292
      0  

    Default

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

  5. #5
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,318
    Answers
    3883
    Vote Rating
    1292
      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 @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.

  7. #7
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    San Jose, California
    Posts
    70
    Answers
    1
    Vote Rating
    0
      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
      0  

    Default

    Not Sencha Touch

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
  •