Can cellcontextmenu handler pass params to menu

  • Obviously in my cellcontextmenu handler I can simply set a global variable to whatever value I want, and then access that global variable within my context menu or the menu item handlers. However, this does not seem very OO, Ext, or Web 2.0. That is, it doesn't seem sexy enough. (And really, isn't it all about writing sexy code?! 8-)

    Is there a smart, scoped, way for my handler to pass current information to the menu--or really, to the menu item's handlers.

    For example, take a grid for example. Assume that row 3, column 5 contains the value "foo". When you right-click this cell, a context menu pops and one of the menu items is "Hide all rows with this value". When you click that menu item, you want a handler to execute a custom FilterBy on the grid's store that will hide all rows where the 5th column = "foo".

    So obviously, I need to somehow pass the value "foo" to the menu item's handler.

    The way that context menus are created in the examples then displayed using contextMenu.showAt(#,#), I don't see how I can pass the value "foo" to the menu. (Alternatively, the right-clicked row and cell index would work or something that I can use to derive the value "foo".)

    OK, now that I've written a book, what I'm asking is, what is the best way to pass a value from the cellcontextmenu handler to a menu's item handler?


  • You can add properties to menu items.


  • You can add properties to menu items.
    Doh! I got to get comfortable with using javascript this way--that everything is an object with properties and methods. You can make up new properties simply by assigning values to them:


    myContextMenu.row = grid.store.data.items[rowIndex];
    myContextMenu.showAt([coords[0], coords[1]]);


    Then, in the context menu item handlers, I can reference myContextMenu.row which gives me access to all the column's values.

    Thanks, Animal.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Can cellcontextmenu handler pass params to menu , Please add it free.