Reputation: 1741
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:
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
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