Nagaraj Krishnappa
Nagaraj Krishnappa

Reputation: 31

Get reference to itemId in Extjs

I have a Window class like this:

Ext.define('EMS.tf.alerts.alerts.view.AlertWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.ems-alerts-window',
    height: 220,
    width: 600,
    alertTpl: undefined,
    autoScroll: true,
    selectedRecord: undefined,
    title: undefined,
    atext: undefined,

    // @private
    initComponent: function() {
        var me = this;

        Ext.apply(me, {
            tpl: me.alertTpl,
            listeners: {
            show: function() {
                Ext.create('Ext.Container', {
                    renderTo: 'alertContainer',
                    itemId: 'buttonContainer',
                    items   : [{
                            xtype: 'button',
                            cls: 'ackbtn',
                            text : 'Acknowledge',
                            name: 'ackButton',
                            itemId: 'renderbutton'
                        },{
                            xtype: 'button',
                            cls: 'attchmntbtn',
                            text : 'Attachment',
                            name: 'attButton',
                            itemId: 'renderattachmntbutton'
                        }]
                    });
                }
            },          
            title: me.title
        });
        me.callParent();
    }
});

I want to get reference to button "Attachment" using itemId "renderattachmntbutton". How to do this?

I tried windowobject.down('#renderattachmntbutton') but still it didn't work. I can get reference to the items placed before init function but not like this. Any idea on what needs to be done to get reference to this button?

Upvotes: 2

Views: 6367

Answers (4)

Naveen Ramawat
Naveen Ramawat

Reputation: 1445

Try this

Ext.ComponentQuery.query('[itemId=renderattachmntbutton]')[0]

Upvotes: 3

Naveen Ramawat
Naveen Ramawat

Reputation: 1445

You could try

windowobject.down('[itemId=renderattachmntbutton]') ;

Upvotes: 1

Saki
Saki

Reputation: 5856

That button is not an item (a child) of the window but of the button container. If you want to find it with down then you need to grab a reference to the container and call down on that.

Instead of

windowobject.down('#renderattachmntbutton') // WRONG

call

buttoncontainer.down('#renderattachmntbutton') // Correct

Upvotes: 2

mindparse
mindparse

Reputation: 7315

The itemId can be used with the getComponent() call on parent items, like container and panels. If you change your itemId on your container to just an id property. You can then get to your child items like so:

Ext.getCmp('buttonContainer').getComponent('renderattachmntbutton');

This is just one possible way, there are others!

Upvotes: 1

Related Questions