Kire Programista
Kire Programista

Reputation: 25

Vaadin add Grid in table

I have the following code:

GridLayout grid = new GridLayout(3, 3);
grid.addComponent(btnRemove, 0, 0);
grid.addComponent(lblIstMenge, 1, 0);
grid.addComponent(btnAdd, 2, 0);
int i = 0;
if (vList != null && vList.size() > 0)
{
    for (VTr component : vList)
    {
        String transactionTypeName = component.getTransactionTypeName();
        transaktionTable.addItem(new Object[]{++transaktionTableCounter + "", 
          transactionTypeName,
          "123123123123123", grid, "Bemerkung^^^"}, 
          transaktionTableCounter);
        // System.out.println("Grid: " + grids.get(i));
      }
}

Which gives me something like this:

Example of grid

So the grid is added only in the last column. I have tried creating different grids for each column in a list but this did not work for me.

If you have any ideas or recommendations it would be nice.

Upvotes: 0

Views: 85

Answers (1)

Kire Programista
Kire Programista

Reputation: 25

When I move the instantiation of the buttons and grids inside the for loop it is working as expected.

                    int i = 0;
                    if (vList != null && vList.size() > 0)
                    {
                        for (VTr component : vList)
                        {

   btnAdd = new Button();
   btnAdd.setIcon(new ThemeResource("images/btnIncrease.png"));
                            btnRemove = new Button();
                            btnRemove.setIcon(new ThemeResource("images/btnDescrease.png"));
     GridLayout grid = new GridLayout(3, 3);
                    grid.addComponent(btnRemove, 0, 0);
                    grid.addComponent(lblIstMenge, 1, 0);
                    grid.addComponent(btnAdd, 2, 0);        
                            String transactionTypeName = component.getTransactionTypeName();
                            transaktionTable.addItem(new Object[]{++transaktionTableCounter + "", transactionTypeName,
                                "123123123123123", grid, "Bemerkung^^^"}, transaktionTableCounter);

                        }

                    }

Upvotes: 1

Related Questions