Grid: Copy a row from one grid into another grid

With a table i copy rows from one table to the other by this code

public void copydata(){ Object o = table1.getValue(); if(!table2.getItemIds().contains(o)) table2.addItem(o); table2.setContainerDataSource(table2.getContainerDataSource()); } How can i make it with a grid.
Here i have no grid1.getValue();

Table’s getValue() returns the item ID of the currently selected item. In Grid, there’s getSelectedRow() for that.

Also, you’re using item IDs as row captions. I’m not sure if I remember correctly, but I think Grid doesn’t support that, but you need to use a real or generated column.

I have no idea what you are doing with “table2.setContainerDataSource(table2.getContainerDataSource());”