Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin Grid & ButtonRenderer: How to get two buttons in one cell?
I'm using Vaadin 8 together with Spring Framework.
I added a com.vaadin.ui.Grid to my View and set the items via setItems(...). Everything works fine.
Now, I want to add two buttons into the last column of each item. Just to make it clear what I like to do: I like to have two buttons in one cell of my grid.
As the Vaadin Wiki tells me (https://vaadin.com/docs/-/part/framework/components/components-grid.html), I have to use a ButtonRenderer in order to add buttons to a grid. But as far as I understand, a ButtonRenderer just renders one colums at one time. Thus, a ButtonRenderer enables me to add one button per cloumn (works fine so far) and not two buttons in one colum. Am I right in assuming that?
(Using a Vaadin Table, I was able to use addContainerProperty(...) handing over a Panel with two buttons to get what I want. But I do not have any clue about how I can achieve this with a Grid.)
Can anybody support me with a solution for that issue?
Thank you very much in advance.
This is not yet directly supported in Grid. There existis ActionRenderer (https://vaadin.com/directory/#!addon/gridactionrenderer-add-on) for Vaadin 7, with modifications it may work with Vaadin 8. There are plans to have improved component support in Grid in Vaadin 8.1.
There is also another design option. Instead of buttons you could use ContextMenu with right mouse button click for actions that are specific to rows. This will reduce visual clutter, makes UI more compact (less columns), makes UI more performant. If your use case is not related to this, then perhaps not applicable.