-1

How do I add a 2x click listener on a vaadin grid? When I 2x click on it, it takes me to another page. Example would be most appreciated.

Null
  • 139
  • 5
  • 14
  • This question doesn't meet Stackoverflow quality standards. Please refer to [How to ask](http://stackoverflow.com/help/how-to-ask) – kittikun Oct 27 '15 at 02:00

2 Answers2

3

With the MouseEvent you can simply ask for a double click.

See here #MouseEvents.ClickEvent.html#isDoubleClick()

Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
2

Here is an example:

grid.addItemClickListener(listener -> 
    { 
       if (listener.getMouseEventDetails().isDoubleClick())
          // pass the row/item that the user double clicked
          // to method doStuff.
          doStuff(l.getItem());
    }
);
Brett Sutton
  • 3,900
  • 2
  • 28
  • 53
  • Hi @Brett, i'm using Vaadin 7 and trying to get Double click event for the grid, but i couldn't have getMouseEventDetails() method. Instead i have the isDoubleClick() method, like below, grid.addItemClickListener(e -> { if(e.isDoubleClick()) { System.out.println("Double click"); } else { System.out.println("Single click"); } }); But, when i do double click, it's fall under single click only. How to overcome this issue. – Pearl Apr 29 '19 at 11:41
  • @Pearl please have a look at the comment below the accepted answer. I think the described scenario is the same that you have. if you `setEditorEnabled(false)` then `e.isDoubleClick()` returns true. – codinghaus Apr 29 '19 at 12:23
  • @codinghaus, if there is any way to differentiate single click and double click if we set the setEditorEnabled(true). – Pearl Apr 29 '19 at 12:31