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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Answers
    3976
    Vote Rating
    1381
      0  

    Default

    In initComponent you should be able to access your customField via this.customField.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    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
  •