Results 1 to 6 of 6

Thread: this.ownerCt.ownerCt.close(); feels weird..

  1. #1

    Red face this.ownerCt.ownerCt.close(); feels weird..

    Hi,


    this.ownerCt.ownerCt.close();

    basically this
    <button>.<panel>.<window>.close();

    is there a more elegant way to access the close method on the window from any level?

    just curious..

  2. #2
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Thumbs up

    If you gave the Window a component id:

    id:'myWin'

    then..
    Code:
    var w= Ext.getCmp('myWin')
    if(w){
       w[w.closeAction]();
    }
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3

    Default Ext.getCmp

    That sounds about right, does it traverse the entire DOM looking for it?

    Quote Originally Posted by hendricd View Post
    If you gave the Window a component id:

    id:'myWin'

    then..
    Code:
    var w= Ext.getCmp('myWin')
    if(w){
       w[w.closeAction]();
    }

  4. #4
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    No, ComponentMgr maintains a hash of Components (not Elements in this case) by id. Quite fast.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    If IDs are arbitary (as they are in our app where any application component can be popped up at any time, and so cannot have hardcoded IDs), then you have to proceed from a local reference point either up or down to "find" things.

    I'd favour:

    Code:
    var w = this.findParentByType('window');
    if (w) .close();

  6. #6

    Red face

    Quote Originally Posted by Animal View Post
    If IDs are arbitary (as they are in our app where any application component can be popped up at any time, and so cannot have hardcoded IDs), then you have to proceed from a local reference point either up or down to "find" things.

    I'd favour:

    Code:
    var w = this.findParentByType('window');
    if (w) .close();
    Much better... for those newbies reading this (like me) dont forget to
    register your "extended component"

    E.g.
    Ext.reg('OfficesWindow', Ext.GT.OfficesWindow);

    Then you can do
    var w = this.findParentByType('OfficesWindow');

    this is far more elegant than my original approach...

    ps: Thanks Animal!

Posting Permissions

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