use of com.vaadin.flow.component.grid.GridSingleSelectionModel in project flow-components by vaadin.
the class GridSingleSelectionPage method buildToggle.
@SuppressWarnings("rawtypes")
private NativeButton buildToggle(Grid grid, String id) {
NativeButton button = new NativeButton("Toggle deselectAllowed", e -> {
GridSingleSelectionModel gssm = (GridSingleSelectionModel) grid.getSelectionModel();
gssm.setDeselectAllowed(!gssm.isDeselectAllowed());
});
button.setId(id);
return button;
}
use of com.vaadin.flow.component.grid.GridSingleSelectionModel in project flow-components by vaadin.
the class GridSingleSelectionPage method setDeselectAllowedAndSetItems.
private Grid<String> setDeselectAllowedAndSetItems() {
Grid<String> grid = new Grid<>();
GridSingleSelectionModel gssm = (GridSingleSelectionModel) grid.getSelectionModel();
// Set deselectAllowed to false
gssm.setDeselectAllowed(false);
// Set Items for grid
grid = setItemsGrid(grid, ITEMS_GRID);
Button text = new Button();
grid.addSelectionListener(e -> {
if (e.getFirstSelectedItem().isPresent()) {
text.setId("item" + e.getFirstSelectedItem().get());
text.setText("The row " + e.getFirstSelectedItem().get() + " is selected");
add(text);
}
});
return grid;
}
Aggregations