Results 1 to 6 of 6

Thread: How to access the component using itemId

  1. #1

    Default How to access the component using itemId

    Hi ,

    I want to use the same component in the multiple tab but I'm facing the problem as I had given the ID for the component, I read that we can use the itemId but i'm facing the problem in accessing the component using itemId, can any one tell me how to access the component using the item id, Here is the sample code I'm using :

    PostLoginPage.AbrvPatientInfoPanel = Ext.extend(Ext.Panel, {

    initComponent:function() {
    abrvInfoPanelConfig = {
    store:abrvpatientInfoStore,
    plain:true,
    closable:true,
    layout: 'form',
    items:
    [

    {
    height: '20%',
    anchor: '100%',
    xtype:'panel',
    layout:'form',
    region:'center',
    labelWidth:200,
    items:
    [
    {
    xtype:'label',
    itemId:'abrvLastName'
    },}]

    };

    // apply config
    Ext.apply(this, Ext.apply(this.initialConfig, abrvInfoPanelConfig));

    // call parent

    PostLoginPage.AbrvPatientInfoPanel.superclass.initComponent.apply(this,
    arguments);

    }//eo init component
    });
    Ext.reg('abrvPatientInfoPanel', PostLoginPage.AbrvPatientInfoPanel);

    I want to access the component in red outside..

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    hi rchavan,

    here is the example from the api-docs:

    Code:
    var c = new Ext.Panel({ //
        height: 300,
        renderTo: document.body,
        layout: 'auto',
        items: [
            {
                itemId: 'p1',
                title: 'Panel 1',
                height: 150
            },
            {
                itemId: 'p2',
                title: 'Panel 2',
                height: 150
            }
        ]
    })
    p1 = c.getComponent('p1'); // not the same as Ext.getCmp()
    p2 = p1.ownerCt.getComponent('p2'); // reference via a sibling
    another quite nice config for this accessing-problem is "ref".


    kind regards,
    tobiu
    Best regards
    Tobias Uhlig

  3. #3

    Default

    Hi thanks for the reply,

    But I'm using the component another way i.e. registering the component and making the xtype to use it at the multiple places...

  4. #4
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    so?

    Code:
    p1 = c.getComponent('p1');
    says parent.getChildComponentWithItemId(x).

    as long as you know who the parent is, this is fine.
    though "ref" is more flexible, since you can climb up the ownerCts further.


    kind regards,
    tobiu
    Best regards
    Tobias Uhlig

  5. #5

    Default

    HI,

    I'm bit new to extjs,

    I'm using above component as xtype in another panel so can you please tell me which one be the parent for my red marked component..

  6. #6
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    it is not written in your code -> there is only the constructor.

    if you call
    Code:
    var c = new PostLoginPage.AbrvPatientInfoPanel({...});
    or define the parent with
    Code:
    xtype : 'abrvPatientInfoPanel'
    then that should be your parent to fetch.
    Best regards
    Tobias Uhlig

Posting Permissions

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