Class ComboBoxDataView<T>
- Type Parameters:
T
- the item type
- All Implemented Interfaces:
DataView<T>
,Serializable
ListDataProvider
or BackEndDataProvider
.- See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.data.provider.AbstractDataView
component, dataProviderSupplier, NULL_IDENTIFIER_ERROR_MESSAGE, NULL_ITEM_ERROR_MESSAGE
-
Constructor Summary
ConstructorDescriptionComboBoxDataView
(DataCommunicator<T> dataCommunicator, ComboBoxBase<?, T, ?> comboBox) Creates a new generic data view for ComboBox and verifies the passed data provider is compatible with this data view implementation. -
Method Summary
Modifier and TypeMethodDescriptionAdd an item count change listener that is fired when the item count changes.getItem
(int index) Gets the item at the given index from the data available in the ComboBox's server-side.getItems()
Gets the items available on the ComboBox's server-side.protected Class<?>
Returns supportedDataProvider
type for thisDataView
.void
setIdentifierProvider
(IdentifierProvider<T> identifierProvider) Sets an identifier provider, which returns an identifier for the given item.Methods inherited from class com.vaadin.flow.data.provider.AbstractDataView
addIdentifierProviderChangeListener, equals, getIdentifierProvider, refreshAll, refreshItem, verifyDataProviderType
-
Constructor Details
-
ComboBoxDataView
Creates a new generic data view for ComboBox and verifies the passed data provider is compatible with this data view implementation.- Parameters:
dataCommunicator
- the data communicator of the componentcomboBox
- the ComboBox
-
-
Method Details
-
getItem
Gets the item at the given index from the data available in the ComboBox's server-side.This method does not take into account the ComboBox client-side filtering, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.
- Parameters:
index
- item index number- Returns:
- item on index
- Throws:
IndexOutOfBoundsException
- requested index is outside of the data set
-
getSupportedDataProviderType
Description copied from class:AbstractDataView
Returns supportedDataProvider
type for thisDataView
.- Specified by:
getSupportedDataProviderType
in classAbstractDataView<T>
- Returns:
- supported data provider type
-
getItems
Gets the items available on the ComboBox's server-side.This method does not take into account the ComboBox client-side filtering, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.
-
setIdentifierProvider
Description copied from interface:DataView
Sets an identifier provider, which returns an identifier for the given item. The identifier is used for comparing the equality of items. Usage example:dataView.setIdentifiedProvider(Item::getId);
.- Specified by:
setIdentifierProvider
in interfaceDataView<T>
- Overrides:
setIdentifierProvider
in classAbstractDataView<T>
- Parameters:
identifierProvider
- function that returns the non-null identifier for a given item
-
addItemCountChangeListener
public Registration addItemCountChangeListener(ComponentEventListener<ItemCountChangeEvent<?>> listener) Add an item count change listener that is fired when the item count changes. This can happen for instance when filtering the items.Item count change listener is bound to the component and will be retained even if the data changes by setting of a new items or
DataProvider
to component.NOTE: when the component supports lazy loading (implements
HasLazyDataView
) and a count callback has not been provided, an estimate of the item count is used and increased until the actual count has been reached. When the estimate is used, the event is fired with theItemCountChangeEvent.isItemCountEstimated()
returningtrue
.Combo box fires
ItemCountChangeEvent
and notifies all the listeners added by this method, if the items count changed, for instance, due to adding or removing an item(s).ComboBox's client-side filter change won't fire
ItemCountChangeEvent
, since it doesn't change the item count on the server-side, but only makes it easier for users to search through the items in the UI.- Specified by:
addItemCountChangeListener
in interfaceDataView<T>
- Overrides:
addItemCountChangeListener
in classAbstractDataView<T>
- Parameters:
listener
- item count change listener to register- Returns:
- registration for removing the listener
-