MrMaavin
MrMaavin

Reputation: 1741

Vaadin-Grid: Select all check box does not work in the UI

Problem:

I have a grid with lazy loading and therefore my data is not in memory.

To show the check box to select/deselct all i used this Question. My code looks like this:

Grid<CustomClass> grid;
...
// set selection mode
grid.setSelectionMode(SelectionMode.MULTI);
// make select all check box visible
GridSelectionModel<CustomClass> selectionModel = grid.getSelectionModel();
((GridMultiSelectionModel<CustomClass>) selectionModel)
    .setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility.VISIBLE);

The Problem is, that the check box does not work in the UI as you can see:

enter image description here

If i log the selected items with the following code the check box works as expected

grid.addSelectionListener(l -> {
    log.info("selected: " + l.getAllSelectedItems().size());
});

Question:

What can i do that the check box also works in the UI?

Upvotes: 1

Views: 615

Answers (1)

MrMaavin
MrMaavin

Reputation: 1741

The Solution i found that the checkoxes are updated in the UI is to add dataPovider.refreshAll() in the listener.

Code of the Solution:

grid.addSelectionListener(l -> {
    ...
     dataPovider.refreshAll();
    ...
});

Upvotes: 1

Related Questions