com.vaadin.flow.component.grid.
Class AbstractGridSingleSelectionModel<T>
Type Parameters:
T
- the grid type
All Implemented Interfaces:
GridSelectionModel<T>
, GridSingleSelectionModel<T>
, DataGenerator<T>
, SelectionModel<Grid<T>,
, SelectionModel.Single<Grid<T>,
, Serializable
Abstract implementation of a GridSingleSelectionModel.
Author:
Vaadin Ltd.
See Also:
-
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> -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for passing a reference of the grid to this implementation.
-
Method Summary
Modifier and TypeMethodDescriptionaddSelectionListener
(SelectionListener<Grid<T>, T> listener) Adds a generic listener to this selection model, accepting both single and multiselection events.
addSingleSelectionListener
(SingleSelectionListener<Grid<T>, T> listener) Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
SingleSelect<Grid<T>,
T> Gets a wrapper to use this single selection model as a single select in
Binder
.void
Deselects the given item.
void
deselectFromClient
(T item) Handles the deselection of an item that originates from the client.
protected abstract void
fireSelectionEvent
(SelectionEvent<Grid<T>, T> event) Method for handling the firing of selection events.
void
generateData
(T item, elemental.json.JsonObject jsonObject) Adds custom data for the given item to its serialized
JsonObject
representation.Returns the currently selected item, or an empty optional if no item is selected.
boolean
Gets whether it's allowed to deselect the selected row through the UI.
boolean
isSelected
(T item) Returns whether the given item is currently selected.
protected void
remove()
Remove this extension from its target.
void
Selects the given item.
void
selectFromClient
(T item) Handles the selection of an item that originates from the client.
void
setDeselectAllowed
(boolean deselectAllowed) Sets whether it's allowed to deselect the selected row through the UI.
Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, getGrid, refresh
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.DataGenerator
destroyAllData, destroyData, refreshData
Methods inherited from interface com.vaadin.flow.data.selection.SelectionModel.Single
deselectAll, getFirstSelectedItem, getSelectedItems, setSelectedItem
-
Constructor Details
-
AbstractGridSingleSelectionModel
Constructor for passing a reference of the grid to this implementation.
Parameters:
grid
- reference to the grid for which this selection model is created
-
-
Method Details
-
selectFromClient
Description copied from interface:
GridSelectionModel
Handles the selection of an item that originates from the client.
Specified by:
selectFromClient
in interfaceGridSelectionModel<T>
Parameters:
item
- the item being selected -
select
Description copied from interface:
SelectionModel
Selects the given item. Depending on the implementation, may cause other items to be deselected. If the item is already selected, does nothing.
Specified by:
select
in interfaceSelectionModel<Grid<T>,
T> Specified by:
select
in interfaceSelectionModel.Single<Grid<T>,
T> Parameters:
item
- the item to select, not null -
deselectFromClient
Description copied from interface:
GridSelectionModel
Handles the deselection of an item that originates from the client.
Specified by:
deselectFromClient
in interfaceGridSelectionModel<T>
Parameters:
item
- the item being deselected -
deselect
Description copied from interface:
SelectionModel
Deselects the given item. If the item is not currently selected, does nothing.
Specified by:
deselect
in interfaceSelectionModel<Grid<T>,
T> Parameters:
item
- the item to deselect, not null -
isSelected
Description copied from interface:
SelectionModel
Returns whether the given item is currently selected.
Specified by:
isSelected
in interfaceSelectionModel<Grid<T>,
T> Parameters:
item
- the item to check, not nullReturns:
true
if the item is selected,false
otherwise -
getSelectedItem
Description copied from interface:
SelectionModel.Single
Returns the currently selected item, or an empty optional if no item is selected.
Specified by:
getSelectedItem
in interfaceSelectionModel.Single<Grid<T>,
T> Returns:
an optional of the selected item if any, an empty optional otherwise
-
setDeselectAllowed
public void setDeselectAllowed(boolean deselectAllowed) Description copied from interface:
SelectionModel.Single
Sets whether it's allowed to deselect the selected row through the UI. Deselection is allowed by default.
Specified by:
setDeselectAllowed
in interfaceSelectionModel.Single<Grid<T>,
T> Parameters:
deselectAllowed
-true
if the selected row can be deselected without selecting another row instead; otherwisefalse
. -
isDeselectAllowed
public boolean isDeselectAllowed()Description copied from interface:
SelectionModel.Single
Gets whether it's allowed to deselect the selected row through the UI.
Specified by:
isDeselectAllowed
in interfaceSelectionModel.Single<Grid<T>,
T> Returns:
true
if deselection is allowed; otherwisefalse
-
asSingleSelect
Description copied from interface:
GridSingleSelectionModel
Gets a wrapper to use this single selection model as a single select in
Binder
.Specified by:
asSingleSelect
in interfaceGridSingleSelectionModel<T>
Returns:
the single select wrapper
-
addSelectionListener
Description copied from interface:
SelectionModel
Adds a generic listener to this selection model, accepting both single and multiselection events.
Specified by:
addSelectionListener
in interfaceSelectionModel<Grid<T>,
T> Parameters:
listener
- the listener to add, notnull
Returns:
a registration handle for removing the listener
-
addSingleSelectionListener
Description copied from interface:
GridSingleSelectionModel
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.
Specified by:
addSingleSelectionListener
in interfaceGridSingleSelectionModel<T>
Parameters:
listener
- the single selection listener, notnull
Returns:
a registration for the listener
-
generateData
Description copied from interface:
DataGenerator
Adds custom data for the given item to its serialized
JsonObject
representation. This JSON object will be sent to client-side DataProvider.Specified by:
generateData
in interfaceDataGenerator<T>
Parameters:
item
- the data item being serializedjsonObject
- the JSON object being sent to the client -
remove
protected void remove()Description copied from class:
Grid.AbstractGridExtension
Remove this extension from its target.
Overrides:
remove
in classGrid.AbstractGridExtension<T>
-
fireSelectionEvent
Method for handling the firing of selection events.
Parameters:
event
- the selection event to fire
-