Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to set record level context menu on ListGrid

    It seems like a simple thing, but I'm just not seeing it. I want to set a context menu on a ListGrid where the context is the specific row that was contextClicked. I've tried ListGrid.setContextMenu but the menu only shows up when I context-click somewhere in the ListGrid canvas area but *not* on a row. If I context-click on a row nothing happens. What am I missing. Is there a SmartGWT example that shows a row level context menu?

    #2
    What's wrong with cellContextClick?

    Comment


      #3
      Nothing. It works like a charm except that my "context" menu is at the top-left corner of the browser window, not where the mouse button was clicked. How do I get the menu to show up where you would expect it to be?

      Comment


        #4
        As with any component, setLeft() and setTop(), in this case to the mouse coordinates (EventHandler.getX()/getY()).

        Comment


          #5
          I "got it" finally. You still have to setContextMenu on the grid and *add* a ContextClickHandler to show the menu. I thought the two were somehow linked so that just setting a context menu would automate the context click handling. Makes sense. Just wasn't clear to me at first.

          Comment


            #6
            isc_version=8.3.js
            isc_build=3.1p.2013-10-24
            FF and IE

            Hi,

            I had also this problem and solved it by
            grid.addCellContextClickHandler(new CellContextClickHandler)
            and
            appMenu.moveTo(EventHandler.getX(), EventHandler.getY())
            but now when I context-select the last row on the gird the menu is trapped. When setting the menu as contextMenu on the widget the menu is shown on the above side, also managed automatically when the bottom border of the window nears the widget, please see the attachment.

            Should I now for such cases manually estimate the position of the menu?

            Regards,
            zapryano
            Attached Files

            Comment


              #7
              Menu.showContextMenu() will show a menu near the current mouse coordinates, automatically avoiding placing the menu partly offscreen.

              Comment

              Working...
              X