Kiesa Kiesa - 7 days ago 6
Java Question

Horizontal OptionGroup in a Table (Vaadin)

I' tryind to add an OptionGroup to my table, but so far the table stays empty no matter what I do.

Here is what I've tried so far:

table = new Table();
table.setSizeFull();
table.addContainerProperty("Name", String.class, null);
table.addContainerProperty("Option one", OptionGroup.class, null);
table.addContainerProperty("Option two", OptionGroup.class, null);
opt1 = new OptionGroup("");
opt1.addItem();
opt1.addItem();
opt1.setMultiSelect(false);
table.addItem(new Object[] {"Name one", opt1.getItem(1),opt1.getItem(2)}, new Integer(1));


Am I missing something, or is it not so easy to solve this as shown in my example?

Ben Ben
Answer

Just a quick look, but it seem you are not adding any Option Group Options.

Have you tried just addeding the Option class itself

table = new Table();
table.addContainerProperty("Name", String.class, null);
table.addContainerProperty("Option one", OptionGroup.class, null);
opt1 = new OptionGroup("Time");
opt1.addItem("AM");     
opt1.addItem("PM");
table.addItem(new Object[] {"Name one", opt1}, new Integer(1));

I would also remove the setSizeFull()

Also the null, will be the default value if something goes wrong.

once you have that working, you can use CSS to arrange the options Horizontally.

Comments