Results 1 to 5 of 5

Thread: what is "this" in toolbar button click event

  1. #1
    Sencha User Bogdan0x400's Avatar
    Join Date
    Dec 2010
    Location
    Ukraine, Kiev
    Posts
    55

    Question what is "this" in toolbar button click event

    I have an editorgrid and a toolbar with a button. What gets passed as this parameter when the user clicks the toolbar button? I get DispHTMLWindow2 as this parameter, but I can't figure out for what Ext component it stands.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    http://dev.sencha.com/deploy/dev/doc...n&member=scope

    The scope (this reference) in which the handler and toggleHandler is executed. Defaults to this Button.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User Bogdan0x400's Avatar
    Join Date
    Dec 2010
    Location
    Ukraine, Kiev
    Posts
    55

    Default

    So if I have code like:
    PHP Code:
    var grid = new Ext.grid.EditorgridPanel({
        
    tbar: [
                                     {
                                         
    text'New',
                                         
    handler: function () {
    alert("toolbar button clicked");
                                         },
                                         
    scopethis
                                     
    }
    ]
    }); 
    then in the handler function I'll get a grid reference in this, right?

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

    Default

    No. 'this' will be the value of 'this' at the time you created the grid (it's evaluated before the grid is created!).

    If you want a grid reference, then I would recommend:
    Code:
    handler: function(btn) {
      var grid = btn.findParentByType('grid');
      ...
    }

  5. #5
    Sencha User Bogdan0x400's Avatar
    Join Date
    Dec 2010
    Location
    Ukraine, Kiev
    Posts
    55

    Default

    Thanks for the answers, Condor and Evant!

Similar Threads

  1. "passing google maps gevents to extjs" or "simulate mouse click"
    By thomas.oberthanner in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 11 Aug 2011, 6:06 AM
  2. Editor Grid: how to handle server response when click on "Save" button
    By Deeeem in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 13 Jul 2010, 7:28 AM
  3. Replies: 7
    Last Post: 2 Jul 2010, 11:19 PM
  4. Now "right-click" or "contextmenu" event on Button?
    By dbassett74 in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 11 Jul 2009, 10:19 AM
  5. Toolbar button "click" event firing on load
    By levay in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 5 Dec 2007, 11:47 PM

Posting Permissions

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