Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select all row in vaadin table?

Tags:

vaadin

HI,

I am having one check box and one table and table has 10 rows .If user selects the check box then all the 10 rows in the vaadin table should need to select but i don't know how to achieve this functionality.Can anyone tell me how to achieve this? If possible provide me some code snippet.

like image 566
Kumar Avatar asked Dec 18 '22 01:12

Kumar


2 Answers

Table.getValue() takes either the ID of a single item or a collection of several item ID's, and Table.getItemIds() returns the ID's of all items in the table. This means that you can select all items in the table simply by:

yourTable.setValue(yourTable.getItemIds());

Note that this will cause performance troubles if there are a lot of items in the table's container. Should work in a simple case like yours, though.

like image 165
hezamu Avatar answered Dec 31 '22 15:12

hezamu


Make sure the table has yourTable.setMultiSelect(true) and then just iterate the ID's got from yourTable.getItemIds() and call yourTable.select(id) for all id's. This is one way.

like image 23
Jonas Granvik Avatar answered Dec 31 '22 15:12

Jonas Granvik