Class AbstractGridMultiSelectionModel<T>
- Type Parameters:
T- the grid type
- All Implemented Interfaces:
GridMultiSelectionModel<T>,GridSelectionModel<T>,com.vaadin.flow.data.provider.DataGenerator<T>,com.vaadin.flow.data.selection.SelectionModel<Grid<T>,,T> com.vaadin.flow.data.selection.SelectionModel.Multi<Grid<T>,,T> Serializable
- Since:
- 1.0
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.grid.GridMultiSelectionModel
GridMultiSelectionModel.SelectAllCheckboxVisibilityNested classes/interfaces inherited from interface com.vaadin.flow.data.selection.SelectionModel
com.vaadin.flow.data.selection.SelectionModel.Multi<C extends com.vaadin.flow.component.Component,T>, com.vaadin.flow.data.selection.SelectionModel.Single<C extends com.vaadin.flow.component.Component, T> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractGridMultiSelectionModel(Grid<T> grid) Constructor for passing a reference of the grid to this implementation. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddClientItemToggleListener(com.vaadin.flow.component.ComponentEventListener<ClientItemToggleEvent<T>> listener) Adds a client item toggle listener that will be called when the user toggles the selection state of an item on the client-side.com.vaadin.flow.shared.RegistrationaddMultiSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener<Grid<T>, T> listener) Adds a selection listener that will be called when the selection is changed either by the user or programmatically.com.vaadin.flow.shared.RegistrationaddSelectionListener(com.vaadin.flow.data.selection.SelectionListener<Grid<T>, T> listener) Gets a wrapper to use this multiselection model as a multiselect inBinder.protected voidprotected voidvoidvoidvoiddeselectFromClient(T item) Handles the deselection of an item that originates from the client.protected abstract voidfireSelectionEvent(com.vaadin.flow.data.selection.SelectionEvent<Grid<T>, T> event) Method for handling the firing of selection events.voidgenerateData(T item, tools.jackson.databind.node.ObjectNode jsonObject) Gets the current mode for the select all checkbox visibility.Returns an unmodifiable view of the selected item ids.protected GridSelectionColumnbooleanGets whether grid drag select is enabled or not.booleanReturns whether the select all checkbox will be visible with the current setting ofGridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility)and the type of data set to the Grid (in-memory or lazy).booleanisSelected(T item) booleanGets the selection column's frozen state.booleanGets whether a click on a row toggles the selection of the row's item.protected voidremove()Remove this extension from its target.voidvoidvoidselectFromClient(T item) Handles the selection of an item that originates from the client.voidsetDragSelect(boolean dragSelect) Iftrue, grid rows can be selected or deselected by dragging the mouse cursor over grid's selection column.voidsetSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility) Sets the select all checkbox visibility mode.voidsetSelectionColumnFrozen(boolean frozen) Sets the selection column's frozen state.voidsetSelectOnItemClick(boolean selectOnItemClick) Sets whether a click on a row toggles the selection of the row's item.voidupdateSelection(Set<T> addedItems, Set<T> removedItems) Methods inherited from class com.vaadin.flow.component.grid.Grid.AbstractGridExtension
extend, getGrid, refreshMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.data.provider.DataGenerator
destroyAllData, destroyData, refreshDataMethods inherited from interface com.vaadin.flow.data.selection.SelectionModel.Multi
deselectItems, selectItems
-
Constructor Details
-
AbstractGridMultiSelectionModel
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
-
remove
protected void remove()Description copied from class:Grid.AbstractGridExtensionRemove this extension from its target.- Overrides:
removein classGrid.AbstractGridExtension<T>
-
selectFromClient
Description copied from interface:GridSelectionModelHandles the selection of an item that originates from the client.- Specified by:
selectFromClientin interfaceGridSelectionModel<T>- Parameters:
item- the item being selected
-
deselectFromClient
Description copied from interface:GridSelectionModelHandles the deselection of an item that originates from the client.- Specified by:
deselectFromClientin interfaceGridSelectionModel<T>- Parameters:
item- the item being deselected
-
getSelectedItems
-
getSelectedItemIds
Returns an unmodifiable view of the selected item ids.Exposed to be overridden within subclasses.
The returned Set may be a direct view of the internal data structures of this class. A defensive copy should be made by callers when iterating over this Set and modifying the selection during iteration to avoid ConcurrentModificationExceptions.
- Returns:
- An unmodifiable view of the selected item ids. Updates in the selection may or may not be directly reflected in the Set.
- Since:
- 23.2
-
getFirstSelectedItem
-
select
-
deselect
-
selectAll
public void selectAll() -
deselectAll
public void deselectAll() -
updateSelection
-
isSelected
-
asMultiSelect
Description copied from interface:GridMultiSelectionModelGets a wrapper to use this multiselection model as a multiselect inBinder.- Specified by:
asMultiSelectin interfaceGridMultiSelectionModel<T>- Returns:
- the multiselect wrapper
-
addSelectionListener
-
addMultiSelectionListener
public com.vaadin.flow.shared.Registration addMultiSelectionListener(com.vaadin.flow.data.selection.MultiSelectionListener<Grid<T>, T> listener) Description copied from interface:GridMultiSelectionModelAdds a selection listener that will be called when the selection is changed either by the user or programmatically.- Specified by:
addMultiSelectionListenerin interfaceGridMultiSelectionModel<T>- Parameters:
listener- the multi selection listener, notnull- Returns:
- a registration for the listener
-
addClientItemToggleListener
public com.vaadin.flow.shared.Registration addClientItemToggleListener(com.vaadin.flow.component.ComponentEventListener<ClientItemToggleEvent<T>> listener) Description copied from interface:GridMultiSelectionModelAdds a client item toggle listener that will be called when the user toggles the selection state of an item on the client-side.This event follows
MultiSelectionEventand provides details about the item that was toggled, its new selection state, and whether the shift key was pressed during the selection. This can be helpful for implementing features like range selection.- Specified by:
addClientItemToggleListenerin interfaceGridMultiSelectionModel<T>- Parameters:
listener- the client item toggle listener, notnull- Returns:
- a registration for the listener
-
setSelectAllCheckboxVisibility
public void setSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility) Description copied from interface:GridMultiSelectionModelSets the select all checkbox visibility mode.The default value is
GridMultiSelectionModel.SelectAllCheckboxVisibility.DEFAULT, which means that the checkbox is only visible if the grid's data provider is in-memory.The select all checkbox will never be shown if the Grid uses lazy loading with unknown item count, i.e. no items count query provided to it, and even setting
GridMultiSelectionModel.SelectAllCheckboxVisibility.VISIBLEwon't make it visible.- Specified by:
setSelectAllCheckboxVisibilityin interfaceGridMultiSelectionModel<T>- Parameters:
selectAllCheckBoxVisibility- the visibility mode to use- See Also:
-
getSelectAllCheckboxVisibility
Description copied from interface:GridMultiSelectionModelGets the current mode for the select all checkbox visibility.- Specified by:
getSelectAllCheckboxVisibilityin interfaceGridMultiSelectionModel<T>- Returns:
- the select all checkbox visibility mode
- See Also:
-
isSelectAllCheckboxVisible
public boolean isSelectAllCheckboxVisible()Description copied from interface:GridMultiSelectionModelReturns whether the select all checkbox will be visible with the current setting ofGridMultiSelectionModel.setSelectAllCheckboxVisibility(SelectAllCheckboxVisibility)and the type of data set to the Grid (in-memory or lazy).The select all checkbox will never be shown if the Grid uses lazy loading with unknown item count, meaning that no count callback has been provided. It will also not be shown if the grid is configured to use conditional selection via
Grid.setItemSelectableProvider(SerializablePredicate)- Specified by:
isSelectAllCheckboxVisiblein interfaceGridMultiSelectionModel<T>- Returns:
trueif the checkbox will be visible with the current settings- See Also:
-
generateData
- Specified by:
generateDatain interfacecom.vaadin.flow.data.provider.DataGenerator<T>
-
setSelectionColumnFrozen
public void setSelectionColumnFrozen(boolean frozen) Description copied from interface:GridMultiSelectionModelSets the selection column's frozen state.- Specified by:
setSelectionColumnFrozenin interfaceGridMultiSelectionModel<T>- Parameters:
frozen- whether to freeze or unfreeze the selection column
-
isSelectionColumnFrozen
public boolean isSelectionColumnFrozen()Description copied from interface:GridMultiSelectionModelGets the selection column's frozen state.- Specified by:
isSelectionColumnFrozenin interfaceGridMultiSelectionModel<T>- Returns:
- whether the selection column is frozen
-
setDragSelect
public void setDragSelect(boolean dragSelect) Description copied from interface:GridMultiSelectionModelIftrue, grid rows can be selected or deselected by dragging the mouse cursor over grid's selection column.- Specified by:
setDragSelectin interfaceGridMultiSelectionModel<T>- Parameters:
dragSelect-trueto enable drag select feature,falsefor disabling it
-
isDragSelect
public boolean isDragSelect()Description copied from interface:GridMultiSelectionModelGets whether grid drag select is enabled or not.- Specified by:
isDragSelectin interfaceGridMultiSelectionModel<T>- Returns:
trueif drag select feature is enabled,falseotherwise
-
isSelectOnItemClick
public boolean isSelectOnItemClick()Description copied from interface:GridMultiSelectionModelGets whether a click on a row toggles the selection of the row's item.The default implementation throws an
UnsupportedOperationException. The selection models that Grid uses override it.- Specified by:
isSelectOnItemClickin interfaceGridMultiSelectionModel<T>- Returns:
trueif a click on a row toggles the selection,falseotherwise- See Also:
-
setSelectOnItemClick
public void setSelectOnItemClick(boolean selectOnItemClick) Description copied from interface:GridMultiSelectionModelSets whether a click on a row toggles the selection of the row's item. When enabled, you can select and deselect items with a click anywhere in the row, not only with the checkbox in the selection column.- A click on an item that is not selected selects it. A click on a selected item deselects it.
- Space on a focused row or cell counts as a click.
- A click on focusable content in a cell, such as a button or a text field, does not change the selection.
- The selection of items that
Grid.setItemSelectableProvider(SerializablePredicate)does not allow does not change.
false.The default implementation throws an
UnsupportedOperationException. The selection models that Grid uses override it.- Specified by:
setSelectOnItemClickin interfaceGridMultiSelectionModel<T>- Parameters:
selectOnItemClick-trueto toggle the selection on a click on a row,falseto not change the selection on a click on a row
-
fireSelectionEvent
protected abstract void fireSelectionEvent(com.vaadin.flow.data.selection.SelectionEvent<Grid<T>, T> event) Method for handling the firing of selection events.- Parameters:
event- the selection event to fire
-
clientSelectAll
protected void clientSelectAll() -
getSelectionColumn
-
clientDeselectAll
protected void clientDeselectAll()
-