0

As you see in the title I´m searching for the code to add a simple selectioncell/combobox column in my celltable, the Items don´t come from any database. I haven´t found it anywhere yet. Could someone please answer with the code to add it and how to implement the items?

Thanks

Erasio
  • 43
  • 2
  • 8

1 Answers1

1
public class Main implements EntryPoint
{

    private class Model
    {
        String value;

        public Model(
            String value)
        {
            super();
            this.value = value;
        }

    }

    @Override
    public void onModuleLoad()
    {
        RootPanel.get().add(createTable());
    }

    private Widget createTable()
    {
        CellTable<Model> table = new CellTable<Model>();
        table.addColumn(new Column<Model, String>(new SelectionCell(
            getAcceptableValues()))
        {

            @Override
            public String getValue(
                Model object)
            {
                return object.value;
            }
        });

        table.setRowData(Arrays.asList(new Model("value1"),
            new Model("value2"), new Model("another value")));
        return table;
    }

    private List<String> getAcceptableValues()
    {
        return Arrays.asList("value1", "value2");
    }
}
cardamo
  • 853
  • 4
  • 13