Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to add, select then edit a row in a Grid
I am adding a new row to a Grid by adding a BeanItem to the underlying Container as follows:
BeanItem beanItem = new BeanItem<User>(user);Item item = container.addBean(user);
A new row is successfully appended to the Grid.
My question is: How do I then select that new row so I can something like
grid.editItem(grid.getSelectedRow());
My goal is to have an Add button that adds a new row to my grid, selects that row, then edits that row.
Advice much appreciated!
Cheers
Sean
This depends a bit which type of container you use. It seems that you are using BeanItemContainer, in which case BeanItem itself is also the ItemId. This means that you can directly apply grid.editItem(beanItem); in your case.
Hi Tatu
Thank you for your reply, yes I am using a BeanItemContainer.
I tried the following code based on your suggestion:
User user = new User();BeanItem<User> beanItem = container.addItem(user);fieldGroup.setItemDataSource(beanItem);grid.editItem(beanItem);
The last line produces the following error:
Item with id false not found in current container
I wondered if the id in question was the id field of the user bean, so I saved user after creating it and confirmed it had a valid value, however I got the same error.
Any suggestions?
Cheers
Sean
Problem sorted, the following code worked fine:\
User user = new User(mainMenuBuilder.getDataAccess());BeanItem<User> beanItem = container.addItem(user);fieldGroup.setItemDataSource(beanItem);grid.editItem(user);