1. #1
    Ext JS Premium Member Elijah's Avatar
    Join Date
    Nov 2009
    Location
    USA
    Posts
    382
    Vote Rating
    0
    Elijah is on a distinguished road

      0  

    Default [SOLVED] How can I have the handler call my function?

    [SOLVED] How can I have the handler call my function?


    thank you VinyFox and Animal.

    How can I write this so that I do not have to put all my code into the ... area?
    Code:
    listeners: {
        rowcontextmenu: function(grid, rowIndex, event) {
            ...MyFn logic...
        }
    } // eol
    I also do not want to have to write it like this if I can avoid it.
    Code:
    listeners: {
        rowcontextmenu: function(grid, rowIndex, event) {
            nowCallMyFn(grid, rowIndex, event);
        }
    } // eol
    Last edited by Elijah; 28 Jul 2010 at 6:03 AM. Reason: issue is resolved.

  2. #2
    Sencha - Community Support Team VinylFox's Avatar
    Join Date
    Mar 2007
    Location
    Baltimore, MD
    Posts
    1,501
    Vote Rating
    8
    VinylFox will become famous soon enough VinylFox will become famous soon enough

      0  

    Default


    Place them inline with the component and reference your function.

    PHP Code:
    listeners: {
        
    rowcontextmenuthis.nowCallMyFn,
        
    scopethis
    },
    nowCallMyFn: function(gridrowIndexevent) {
        ...


  3. #3
    Ext JS Premium Member Elijah's Avatar
    Join Date
    Nov 2009
    Location
    USA
    Posts
    382
    Vote Rating
    0
    Elijah is on a distinguished road

      0  

    Default


    How would it possibly know that I want it to fire on the rowcontextmenu if I add it after the listener section?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    What?

  5. #5
    Ext JS Premium Member Elijah's Avatar
    Join Date
    Nov 2009
    Location
    USA
    Posts
    382
    Vote Rating
    0
    Elijah is on a distinguished road

      0  

    Default


    Oops sorry misread Vinyl post.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Of course this.nowCallMyFn will have to exist.

    You will have to be in an initComponent method in a class definition to work that syntax...

  7. #7
    Ext JS Premium Member Elijah's Avatar
    Join Date
    Nov 2009
    Location
    USA
    Posts
    382
    Vote Rating
    0
    Elijah is on a distinguished road

      0  

    Default


    Okay so that works but it's not what I wanted. I guess I want to know if I can just make it work where it would be written something like this.
    Code:
        rowcontextmenu: nowCallMyFunction(sm, rowindx, r, anyThingElseIwant)
    Here is what I have and it works just now how i want it written.
    Code:
                    listeners:{
                        // prevent right clicking menus
                        contextmenu: function(evtObj){
                            evtObj.stopEvent();
                        },
                        // prevent right clicking menus
                        rowcontextmenu: function(thisGrid, rowIndex, evtObj){
                            doRowCtxMenu(thisGrid, rowIndex, evtObj);
                        }, // rowselect
                        rowdblclick: function(argGrid, rowIndex, e) {
                            GLOBAL_EXTJS.popupUrl({url:argGrid.getStore().getAt(rowIndex).data.productURL, winName:'userMgmtWin', options:''});
                        }
                    } //listeners

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Quote Originally Posted by Elijah View Post

    Here is what I have and it works just now how i want it written.
    Code:
                    listeners:{
                        // prevent right clicking menus
                        contextmenu: function(evtObj){
                            evtObj.stopEvent();
                        },
                        // prevent right clicking menus
                        rowcontextmenu: function(thisGrid, rowIndex, evtObj){
                            doRowCtxMenu(thisGrid, rowIndex, evtObj);
                        }, // rowselect
                        rowdblclick: function(argGrid, rowIndex, e) {
                            GLOBAL_EXTJS.popupUrl({url:argGrid.getStore().getAt(rowIndex).data.productURL, winName:'userMgmtWin', options:''});
                        }
                    } //listeners
    What's wrong with that?

  9. #9
    Ext JS Premium Member Elijah's Avatar
    Join Date
    Nov 2009
    Location
    USA
    Posts
    382
    Vote Rating
    0
    Elijah is on a distinguished road

      0  

    Default


    I thought it was wrong. I thought it I was doing a workaround. I thought it was suppose to be rowcontextmenu: nowDoMyFn(..)

    Okay, Thanks guys.

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,506
    Vote Rating
    54
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Well, there IS a problem in that you are writing a function soup application with cleverly named global functions swimming around.

    What function name will you give to some other grid which needs a row context menu handler?

Similar Threads

  1. [2.0.1]fireEvent('click') on buttons don't call handler function
    By kimu in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 25 May 2012, 8:01 AM
  2. [SOLVED] this.handler.call is not a function
    By iceburg in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 5 Jul 2008, 10:06 AM
  3. Handler problem : this.handler.call is not a function
    By niopi in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 13 May 2008, 5:04 AM
  4. dialog and this.handler.call is not a function
    By TopKatz in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 10 Apr 2007, 7:10 AM

Thread Participants: 2