Interface GridMultiSelectionModel<T>
- Type Parameters:
T- the type of items in grid
- All Superinterfaces:
GridSelectionModel<T>,SelectionModel<Grid<T>,,T> SelectionModel.Multi<Grid<T>,,T> Serializable
- All Known Implementing Classes:
AbstractGridMultiSelectionModel
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumState for showing the select all checkbox in the grid's default header row for the selection column.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 TypeMethodDescriptionAdds a client item toggle listener that will be called when the user toggles the selection state of an item on the client-side.addMultiSelectionListener(MultiSelectionListener<Grid<T>, T> listener) Adds a selection listener that will be called when the selection is changed either by the user or programmatically.MultiSelect<Grid<T>, T> Gets a wrapper to use this multiselection model as a multiselect inBinder.Gets the current mode for the select all checkbox visibility.booleanGets whether grid drag select is enabled or not.booleanReturns whether the select all checkbox will be visible with the current setting ofsetSelectAllCheckboxVisibility(SelectAllCheckboxVisibility)and the type of data set to the Grid (in-memory or lazy).booleanGets the selection column's frozen state.default booleanGets whether a click on a row toggles the selection of the row's item.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.default voidsetSelectOnItemClick(boolean selectOnItemClick) Sets whether a click on a row toggles the selection of the row's item.Methods inherited from interface com.vaadin.flow.component.grid.GridSelectionModel
deselectFromClient, selectFromClientMethods inherited from interface com.vaadin.flow.data.selection.SelectionModel
addSelectionListener, deselectAll, getSelectedItems, isSelectedMethods inherited from interface com.vaadin.flow.data.selection.SelectionModel.Multi
deselect, deselectItems, getFirstSelectedItem, select, selectAll, selectItems, updateSelection
-
Method Details
-
asMultiSelect
MultiSelect<Grid<T>,T> asMultiSelect()Gets a wrapper to use this multiselection model as a multiselect inBinder.- Returns:
- the multiselect wrapper
-
addMultiSelectionListener
Adds a selection listener that will be called when the selection is changed either by the user or programmatically.- Parameters:
listener- the multi selection listener, notnull- Returns:
- a registration for the listener
-
addClientItemToggleListener
Adds 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.- Parameters:
listener- the client item toggle listener, notnull- Returns:
- a registration for the listener
- Since:
- 24.7
-
setSelectAllCheckboxVisibility
void setSelectAllCheckboxVisibility(GridMultiSelectionModel.SelectAllCheckboxVisibility selectAllCheckBoxVisibility) Sets 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.- Parameters:
selectAllCheckBoxVisibility- the visibility mode to use- See Also:
-
getSelectAllCheckboxVisibility
GridMultiSelectionModel.SelectAllCheckboxVisibility getSelectAllCheckboxVisibility()Gets the current mode for the select all checkbox visibility.- Returns:
- the select all checkbox visibility mode
- See Also:
-
isSelectAllCheckboxVisible
boolean isSelectAllCheckboxVisible()Returns whether the select all checkbox will be visible with the current setting ofsetSelectAllCheckboxVisibility(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)- Returns:
trueif the checkbox will be visible with the current settings- See Also:
-
setSelectionColumnFrozen
void setSelectionColumnFrozen(boolean frozen) Sets the selection column's frozen state.- Parameters:
frozen- whether to freeze or unfreeze the selection column
-
isSelectionColumnFrozen
boolean isSelectionColumnFrozen()Gets the selection column's frozen state.- Returns:
- whether the selection column is frozen
-
setDragSelect
void setDragSelect(boolean dragSelect) Iftrue, grid rows can be selected or deselected by dragging the mouse cursor over grid's selection column.- Parameters:
dragSelect-trueto enable drag select feature,falsefor disabling it- Since:
- 24.2
-
isDragSelect
boolean isDragSelect()Gets whether grid drag select is enabled or not.- Returns:
trueif drag select feature is enabled,falseotherwise- Since:
- 24.2
-
isSelectOnItemClick
default boolean isSelectOnItemClick()Gets 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.- Returns:
trueif a click on a row toggles the selection,falseotherwise- Throws:
UnsupportedOperationException- if the implementation does not support this feature- Since:
- 25.4
- See Also:
-
setSelectOnItemClick
default void setSelectOnItemClick(boolean selectOnItemClick) Sets 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.- Parameters:
selectOnItemClick-trueto toggle the selection on a click on a row,falseto not change the selection on a click on a row- Throws:
UnsupportedOperationException- if the implementation does not support this feature- Since:
- 25.4
-