Grid and Listeners, ComponentRenderer and documentation


i’m playing with Vaadin 8.1 and the Grid component. Especially i’m trying to use listeners when clicking in cells and rows.
In the documentation (
) this code is mentioned

grid.addCellClickListener(event ->"Value: " + event.getItem() But the method addCellClickListener does not exists in the Grid component.

Then i tried to use grid.addItemClickListener which works really fine, except unfortunately, if the column has an own ComponentRenderer. In this case the event is not fired. Is this intended behaviour?
The same happens with grid.addSelectionListener.

But i have determined that both listeners addItemClickListener and addSelectionListener fires, if i click on the small border between 2 rows. But this is not really usable.

Is this a bug or a feature?


This issue has been reported. However it is not entirely straightforward to say whether it is a bug or not. In some cases you really want to handle the click event with the component and not propagate the event to Gird, in some other cases not. Good examples of first one could be button or editable field. On the other hand if custom component is just showing data you would like to get click thru.

You are right saying, that it could be difficult to distinguish between different listeners (Button, Cell, Row,…) and i understand this will be problematic.
Using the itemClickListener i’m able to get the column and can decide what to do. That’s great, but i do not have only single-line text columns. To format the text i’m using a CssLayout and i don’t a see another solution, except some more complicated components.