Lauri10
(Lauri Turunen)
October 12, 2020, 10:50am
1
Hi
I need a simple multi select mode in which the user can select items on a hierarchical grid with mouse or touch device. No checkboxes on the left, just the selected items coloured. How to do this? Is there some plugin for this, vaadin14?
https://vaadin.com/api/platform/14.4.0/com/vaadin/flow/component/grid/Grid.SelectionMode.html
Thanks.
Tatu2
(Tatu Lund)
October 14, 2020, 6:51am
2
There is “hidden” property in vaadin-grid-flow-selection-column
element, in order to hide you need to use the following JavaScript call:
public void onAttach(AttachEvent event) {
grid.getElement().executeJs("this.getElementsByTagName(\"vaadin-grid-flow-selection-column\")[0]
.hidden = true;");
}
This will render the multiselection column useless, so you need to add item click listener to explicitly select items that you click on row
grid.addItemClickListener(event -> {
MyBean item = event.getItem();
if (grid.getSelectedItems().contains(item)) {
grid.deselect(item);
} else {
grid.select(event.getItem());
}
});