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.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
CssImport when using Component Exporter by Mikhail Shabarov, 4 weeks ago
Select all checkbox in Table with ColumnGenerator
Hy,
everyone
I created a Table with checkboxes.I use Columngenerator, that generate Checkboxes. I want to select all checkbox. How can i solve that?
Last updated on
Hi,
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.
-Olli
Last updated on
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();
checkboxes.add(cb);
return cb;
});
Button button = new Button("Check all checkboxes by clicking here", event -> checkboxes.forEach( checkbox -> checkbox.setValue(true)) );
}
}
Last updated on
You cannot reply to this thread.