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.
Get all Data from Table
Hi guys,
I need a little help on how to get all the data inside a table without using multi-select method.
Hello,
If you want what is selected you can use the getValue() from the Table. It will return a Set<Object> with all selected lines. If you want really all data you can get its container with the getContainerDataSource() and use the getItemIds() if it is a BeanItemContainer.
Regards
Bruno
Thank you for a quick response...
I have actually two tables. table1 holds the data from my datasource(db), each time I select a row, it passes the value to table2 (I already have done this successfully). What I need is to get all the data from table2 and save it on my database when I press a button.
You could probably use the JPAContainer on table2 and that would ease your job. If not you have to take the data through the Table's container as a I told you previously.
Regards
Bruno
Hi bruno, your suggestion works like a charm... Thanks :grin:
Collection i = table2.getContainerDataSource().getItemIds();
for(int x = 1; x <= i.size(); x++){
System.out.println(table2.getItem(x));
}
Ranjit reddit: Hey jet,
How to get data from database into our Vaadin table as i am a starter i dont know much about this please help regarding this.
What kind of database? If you're using SQL, take a look at https://vaadin.com/book/-/page/sqlcontainer.html.
Collection i = table2.getContainerDataSource().getItemIds(); for(int x = 1; x <= i.size(); x++){ System.out.println(table2.getItem(x)); }
this is correct only if the IDs are incrementals like the counter 'x'
you can considre this snippet regarless how the IDs are constructed (incremental, decremental,or randomly)
Collection i = table.getContainerDataSource().getItemIds();
Iterator<?> walker=i.iterator();
for(int x = 1; x <= i.size(); x++)
System.out.println(table.getItem(walker.next()));