Package com.vaadin.flow.data.selection
Interface SelectionModel.Single<C extends Component,T>
- Type Parameters:
T- the type of the items to selectC- the component type
- All Superinterfaces:
SelectionModel<C,,T> Serializable
- All Known Subinterfaces:
GridSingleSelectionModel<T>
- All Known Implementing Classes:
AbstractGridSingleSelectionModel
- Enclosing interface:
- SelectionModel<C extends Component,
T>
A selection model in which at most one item can be selected at a time.
Selecting another item deselects the originally selected item.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.data.selection.SelectionModel
SelectionModel.Multi<C extends Component,T>, SelectionModel.Single<C extends Component, T> -
Method Summary
Modifier and TypeMethodDescriptiondefault voidDeselects all currently selected items, if any.Get first selected data item.Returns the currently selected item, or an empty optional if no item is selected.Returns a singleton set of the currently selected item or an empty set if no item is selected.booleanGets whether it's allowed to deselect the selected row through the UI.voidSelects the given item.voidsetDeselectAllowed(boolean deselectAllowed) Sets whether it's allowed to deselect the selected row through the UI.default voidsetSelectedItem(T item) Sets the current selection to the given item, or clears selection if givennull.Methods inherited from interface com.vaadin.flow.data.selection.SelectionModel
addSelectionListener, deselect, isSelected
-
Method Details
-
select
Selects the given item. If another item was already selected, that item is deselected.- Specified by:
selectin interfaceSelectionModel<C extends Component,T> - Parameters:
item- the item to select
-
getSelectedItem
Returns the currently selected item, or an empty optional if no item is selected.- Returns:
- an optional of the selected item if any, an empty optional otherwise
-
setSelectedItem
Sets the current selection to the given item, or clears selection if givennull.- Parameters:
item- the item to select ornullto clear selection
-
deselectAll
default void deselectAll()Description copied from interface:SelectionModelDeselects all currently selected items, if any.- Specified by:
deselectAllin interfaceSelectionModel<C extends Component,T>
-
getSelectedItems
Returns a singleton set of the currently selected item or an empty set if no item is selected.- Specified by:
getSelectedItemsin interfaceSelectionModel<C extends Component,T> - Returns:
- a singleton set of the selected item if any, an empty set otherwise
- See Also:
-
getFirstSelectedItem
Description copied from interface:SelectionModelGet first selected data item.This is the same as
getSelectedItem()in case of single selection and the first selected item fromSelectionModel.getSelectedItems()in case of multiselection.- Specified by:
getFirstSelectedItemin interfaceSelectionModel<C extends Component,T> - Returns:
- the first selected item.
-
setDeselectAllowed
void setDeselectAllowed(boolean deselectAllowed) Sets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.- Parameters:
deselectAllowed-trueif the selected row can be deselected without selecting another row instead; otherwisefalse.
-
isDeselectAllowed
boolean isDeselectAllowed()Gets whether it's allowed to deselect the selected row through the UI.- Returns:
trueif deselection is allowed; otherwisefalse
-