The SelectionGrid has an executeJS call to hide the multi selection column, which is called in the constructor. When detaching and reattaching the SG, the column is shown again. To fix that, the JS call should be moved from the constructor to the onAttach method of the grid (or an internal AttachListener).
Reproducible example
Simple detach and reattach the Grid using the button.
@Route(value = "selection-grid-issue")
public class SelectionGridIssueView extends Div {
public SelectionGridIssueView() {
setSizeFull();
List<SamplePerson> persons = new ArrayList<>();
persons.add(new SamplePerson("Henry"));
persons.add(new SamplePerson("Indiana"));
persons.add(new SamplePerson("Jones"));
SelectionGrid<SamplePerson> grid = new SelectionGrid<>();
grid.setItems(persons);
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.addColumn(SamplePerson::getName)
.setHeader("Name");
add(new Button("Detach/Reattach", event -> {
if (grid.getParent().isPresent()) {
remove(grid);
} else {
add(grid);
}
}), grid);
}
public static class SamplePerson {
private final String name;
public SamplePerson(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
}
The SelectionGrid has an executeJS call to hide the multi selection column, which is called in the constructor. When detaching and reattaching the SG, the column is shown again. To fix that, the JS call should be moved from the constructor to the onAttach method of the grid (or an internal AttachListener).
Reproducible example
Simple detach and reattach the Grid using the button.
Workaround
Call the JS manually using an attach listener.