Search in sources :

Example 1 with SelectionMode

use of com.vaadin.flow.component.grid.Grid.SelectionMode in project flow-components by vaadin.

the class TreeGridBasicFeaturesPage method createSelectionModeMenu.

@SuppressWarnings("rawtypes")
private void createSelectionModeMenu() {
    LinkedHashMap<String, SelectionMode> options = new LinkedHashMap<>();
    options.put("none", SelectionMode.NONE);
    options.put("single", SelectionMode.SINGLE);
    options.put("multi", SelectionMode.MULTI);
    options.entrySet().forEach(entry -> {
        addAction("Selection mode - " + entry.getKey(), () -> {
            grid.setSelectionMode(entry.getValue());
            if (entry.getValue() == SelectionMode.MULTI) {
                GridSelectionModel model = grid.getSelectionModel();
                if (model instanceof GridMultiSelectionModel) {
                    ((GridMultiSelectionModel) model).setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility.VISIBLE);
                }
            }
        });
    });
}
Also used : GridMultiSelectionModel(com.vaadin.flow.component.grid.GridMultiSelectionModel) GridSelectionModel(com.vaadin.flow.component.grid.GridSelectionModel) SelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SelectionMode (com.vaadin.flow.component.grid.Grid.SelectionMode)1 GridMultiSelectionModel (com.vaadin.flow.component.grid.GridMultiSelectionModel)1 GridSelectionModel (com.vaadin.flow.component.grid.GridSelectionModel)1 LinkedHashMap (java.util.LinkedHashMap)1