Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Getting clicked button parent

  1. #1

    Question Getting clicked button parent

    I'm trying like crazy to get clicked button parent but somehow failing at it.

    I have multiple form panels with buttons and I would like to get the parent panel when I click on a button. I could write this in jquery in under a minute but I just can't figure it out in extjs. What I'm missing is "this", which would place me directly to button. From there I could easily traverse to it's parent.

    Example in jquery.

    $(this).parents(panel_class)

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Code:
    handler: function(btn, e){
      var form = btn.findParentByType('form');
      ...
    }

  3. #3

    Default

    Thank you.

    I did managed to get parent form with ownerCt property. It's just hard to find these things in documentation.

  4. #4
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    Hi,
    My query is similar...
    I have a combo in a form and the form is in a window.
    On 'expand' of the combo I want the window to come to the front.
    What should the function be like?
    Code:
    listeners:
    {
       expand: function(combo){combo.findParent().findParent().toFront();}
    }
    

  5. #5

    Default

    Hm...I've managed to get parent container of parent form of clicked button with code below if that helps?

    Code:
    removeHintRow: function(btn) {
        var btnsForm = btn.ownerCt;
        var btnsContainer = btnsForm.ownerCt;
        var btnsContainerForm = btnsContainer.ownerCt;
    		
        btnsContainerForm.remove(btnsContainer);
        this.doLayout();
    }

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Code:
    combo.findParentByType('window').toFront();
    (but this will focus the window and possibly hide the combobox dropdown again)

  7. #7

    Default

    Just realized that you can chain ownerCt property.

    So instead of 3 lines in code above, you can just write btn.ownerCt.ownerCt.ownerCt.

    I know it's not the best way to do this, but it works exactly how I need it.

  8. #8
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    Thank you, Condor and Killer_B.
    I have 2 windows. The top one contains a combo. When the second window is in focus, if I click on the combo, it shows something like..
    combo.GIF

    Bringing the first window toFront does not help(as Condor predicted). What to do?

    PS: Killer_B, sorry for hijacking your thread

  9. #9
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Write a getListParent method for the ComboBox that returns the body of the window (instead of the document body).

  10. #10
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default

    I wrote this...gives error: object doesn't support this property or method
    (window1 is the id of the window that contains the form that contains the combo)
    Code:
    {
    xtype: 'combo',
    ....
     getListParent : function()
     {
       return Ext.get('window1').getBody();
       //the next line doesn't work either
       return this.findParentByType('window').getBody();
      },
      listeners:
      {
        expand: function(combo){combo.findParentByType('window').toFront();}
     }
    
    }

Page 1 of 2 12 LastLast

Similar Threads

  1. button stay clicked
    By intro in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 28 Oct 2010, 12:28 AM
  2. how do I disable a button after it is clicked.
    By Mthor in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 25 Nov 2008, 10:03 AM
  3. How to check whether button is clicked or not??
    By btb in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 29 Oct 2008, 7:30 AM
  4. check all when button clicked
    By Mthor in forum Ext 2.x: Help & Discussion
    Replies: 22
    Last Post: 11 Jul 2008, 8:06 AM
  5. How do I get the current button clicked
    By ccoley3910 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 13 Feb 2008, 11:29 AM

Tags for this Thread

Posting Permissions

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