Horizontal OptionGroup in a Table

Hi,

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

Here i what i’ve tryed 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.

Hi,

OptionGroup is an atomic entity so you cannot put one item of the Optiongroup by cell.

However, if you a want one OptionGroup by cell, you must change your code a littlebit.


        Table 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);
        OptionGroup opt1 = new OptionGroup("");
        opt1.addItem("item1");    
        opt1.addItem("item2");
        opt1.setMultiSelect(false);
        OptionGroup opt2 = new OptionGroup("");
        opt2.addItem("item1");    
        opt2.addItem("item2");
        opt2.setMultiSelect(false);
        
        table.addItem(new Object[] {"Name one", opt1, opt2}, new Integer(1));

Hope it’s help you.

Regards.

Éric

I answered also to
stackoverflow
but I think you want to use the
FlexibleOptionGroup
add-on.

actualy this is what i need “put one item of the Optiongroup by cell.” is there no way to do it ? maybe not with vaadin with something else.

You can give a try to FlexibleOptionGroup like Henri said.

Can you tell us exactly what your try to do.

So far now, I have difficulty to understand how is your table is bind with the datasource ?

With more explanation, we can suggest something better.

Regards,

Éric.