Results 1 to 3 of 3

Thread: How to pass parameters to inherited custom component?

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    12
    Vote Rating
    0
      0  

    Default Answered: How to pass parameters to inherited custom component?

    For instance I have following base class:
    Code:
    Ext.define('MyCompany.BaseClass', {
        extend: 'Ext.panel.Panel',
    
        // This field I want to initialize
        customField: '',
    
        initComponent: function() {
            this.callParent(arguments);
        }
    });
    And custom derived class:
    Code:
    Ext.define('MyCompany.SubClass', {
        extend: 'MyCompany.BaseClass',
    
        initComponent: function() {
            this.callParent(arguments);
        }
    });
    And then I try to create an instance of subclass with passing a parameter to initialize 'customField':
    Code:
    Ext.create('MyCompany.SubClass', {
        customField: 'Test'
    });
    Where is appropriate place to catch passed parameter in the class hierarchy and initialize necessary field?

  2. In initComponent you should be able to access your customField via this.customField.

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

    Default

    In initComponent you should be able to access your customField via this.customField.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

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

  4. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    12
    Vote Rating
    0
      0  

    Default

    I've tried access it via 'arguments', didn't know that it can be accessed directly. Thanks!

Posting Permissions

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