Search code examples
javascriptextjsextjs4parent-childcustom-component

xtype and itemId properties missing in custom ExtJS component


I created a custom ExtJS by extending Ext.container.Container comprising of controls like radiofield, combo and a dataview and named its alias config as widget.CustomerDetail.

In the actual View, I'm using this component by defining it in items array as follows.

{
    xtype: 'CustomerDetail',
    itemId: 'customerDetail',
    customerId: '<some id>', //this is custom attribute that I access in CustomerDetail's constructor.
    listeners: {
        'customerDataChanged': function(sender, eOpts) {
            //This event is fired from CustomerDetail's components' change events
            //by this.fireEvent("customerDataChanged", obj, eOpts);
            //Do something like enabling Parent form's Save button.
        }
    }
}

But I'm unable to query this custom component in its parent view (the form which uses it) by using this.getComponent('<parent_form_itemId').getComponent('customerDetail').

while, if I just inspect this.getComponent('<parent_form_itemId'), it has whole form object, and its items array also has CustomerDetail component, but surprisingly CustomerDetails object doesn't have xtype or itemId present in it.

What's wrong here?


Solution

  • You can find a child component with down():

    this.down('#customerDetail');
    

    Do not forget the # when you select by itemId.