Finding Grid Row from Embedded Button?

Hi all,
I’m a newbie Vaadin user.

I’m using a grid layout with a column containing an “Add New Row” button. When I click the button, I want to insert a new row directly below the row containing the button. I added a button click listener, but cannot figure out how to get the containing grid’s row number (so I can .insertRow after that row number).

Note, I don’t want to assume the row is the last row because I might have 10 rows populated, and click the button on the 2nd row. That should insert a new 3rd row with all the existing rows shifting down one row.

How can I do this? (if there is a better way than using grid layout, I’m acceptable to that too).


Hi and welcome on board!

You can get the row index of clicked button by
object returned by


final GridLayout grid = new GridLayout();
grid.addComponent(new Button("Add new row after", new ClickListener() {
   public void buttonClick(ClickEvent event) {
	Area a = grid.getComponentArea(event.getButton());
	grid.insertRow(a.getRow1() + 1);
	grid.addComponent(someNewComponent, 0, a.getRow1() + 1);

Thank you! Worked like a charm.

Tried the Class GridLayout.Area method but getting com.vaadin.ui.GridLayout$OverlapsException. Can someone help. Thanx in advance!!!