Announcement

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

    TileGrid -Getting Relevant Record from Context Menu

    Hi,

    I've added a context menu to my TileGrid to allow the user to perform an action on the relevant record when selecting the menu item. I was pouring over the documentation and I could not find a way to get the tile record the context menu was launched from, when in the context handler. The other option I was pondering about was adding a right click listener to each tile, but it seems inefficient to me.
    The snippet of the code is:
    Code:
    		Menu galleryMenu=new Menu();
    		MenuItem selectImageMenuItem=new MenuItem("Select Image");
    		galleryMenu.addItem(selectImageMenuItem);
    		selectImageMenuItem.addClickHandler(new ClickHandler()
    		{
    			
    			@Override
    			public void onClick(MenuItemClickEvent event)
    			{
                           // Could not find a way to get to the clicked record
                           // from here. Could not rely on get selected, since
                           // a right click record is not necessarily previously
                           // selected. So the line below does not solve the issue.
    				chooseImage(galleryGrid.getSelectedRecord());
    				System.out.println(event.toDebugString());
    				
    			}
    		});
    		galleryGrid.setContextMenu(galleryMenu);
    I'm using SmartGWT 2.2 with GWT 2.0.3 running on Windows XP SP3 32bit with Chrome 5.

    Thanks for any suggestion.
    -Gabriel

    #2
    I'm looking for a way to do the same thing. Any equivalent to ListGrid.addCellContextClickHandler() but for TileGrid?

    Comment


      #3
      We're adding this to API the 3.0 release branch. This will show up in nightly builds going forward.

      Jay - a workaround for 2.5 would be to use EventHandler.getTarget() to determine which tile received the mouse event.

      Comment


        #4
        EventHandler.getTarget() gets me the Canvas for the tile that was right-clicked on, but how do I get to the associated Record?

        Comment


          #5
          The Tile object itself has a getRecord() method on it which is a documented API in SmartClient not yet wrapped for SGWT. So you could call that via JSNI and still be using supported APIs (even in 2.5).

          Comment

          Working...
          X