How to add a combobox in a grid?

Hi all,

I am new to Vaadin.
I was trying to add a combox in a grid.

Code -

Grid grid = new Grid();
grid.setWidth(“800px”);
grid.setHeight(“200px”);

grid.addColumn(“Rank”, ComboBox.class );

ComboBox selectRankComboBox = new ComboBox(“”);
Integer rank = new Integer {1, 2, 3, 4, 5};
for (int i : rank){
selectRankComboBox.addItem(i);
}

grid.addRow(selectRankComboBox);

layout.addComponent(grid);

Attached is the screenshot of the output.
It is showing the Id

How can I display the combox in a grid?
22221.jpg

In Grid it is not possible to add component directly to the cell of Grid. Hence the thing you are attempting to do doesn’t work. Instead you could create widget renderer that renders ComboBox or ComboBox like widget (e.g. GWT’s ListBox) in Grid’s cell.

There are couple of example’s here in this add-on.


https://vaadin.com/directory#!addon/grid-renderers-collection-for-vaadin7