Select all checkbox in Table with ColumnGenerator


I created a Table with checkboxes.I use Columngenerator, that generate Checkboxes. I want to select all checkbox. How can i solve that?

Like this:



One way to do it: when you’re creating the CheckBox object, add it to a List that is stored in a member field of the containing class. Once you need to select all checkboxes, just iterate through the list.


can you give me some example? :slight_smile:

Something like this:

public class MyClass extends CustomComponent {
  private List<CheckBox> checkboxes = new ArrayList<>();
  private Table table;
  private Button button;
  // ...
  public void createTable() {
    table = new Table();
    // ...
    table.addGeneratedColumn(columnPropertyId, (source, itemId, columnId) -> {
        CheckBox cb = new CheckBox();
        return cb;
    Button button = new Button("Check all checkboxes by clicking here", event -> checkboxes.forEach( checkbox -> checkbox.setValue(true)) );