com.vaadin.flow.data.provider.
Interface LazyDataView<T>
Type Parameters:
T
- data type
All Superinterfaces:
DataView<T>
, Serializable
All Known Implementing Classes:
AbstractLazyDataView
, ComboBoxLazyDataView
, GridLazyDataView
DataView for lazy loaded data.
Since:
-
Method Summary
Modifier and TypeMethodDescriptionint
Gets the item count estimate.
int
Gets the item count estimate increase - how much the item count estimate is increased once the previous item count estimate has been reached.
void
setItemCountEstimate
(int itemCountEstimate) Sets the estimated item count for the component.
void
setItemCountEstimateIncrease
(int itemCountEstimateIncrease) Sets how much the item count estimate is increased once the previous item count estimate has been reached.
void
Switches the component to get the exact item count from the data provider's
DataProvider.size(Query)
.void
Switches the component to automatically extend the number of items as the previous end is almost reached.
void
setItemIndexProvider
(ItemIndexProvider<T, ?> itemIndexProvider) Sets the item index provider for this lazy data view.
Methods inherited from interface com.vaadin.flow.data.provider.DataView
addItemCountChangeListener, getItem, getItemIndex, getItems, refreshAll, refreshItem, setIdentifierProvider
-
Method Details
-
setItemCountFromDataProvider
void setItemCountFromDataProvider()Switches the component to get the exact item count from the data provider's
DataProvider.size(Query)
. Use this when it is cheap to get the exact item count and it is desired that the user sees the "full scrollbar size". -
setItemCountEstimate
void setItemCountEstimate(int itemCountEstimate) Sets the estimated item count for the component. The component will automatically fetch more items once the estimate is reached or adjust the count if the backend runs out of items before the end. Use this when the backend will have a lot more items than shown by default and it should be shown to the user.
The given estimate is discarded if it is less than the currently shown range or if the actual number of items has been determined. The estimate shouldn't be less than two pages (see
setPageSize(int)
in the component) or it causes unnecessary backend requests.Parameters:
itemCountEstimate
- estimated item count of the backendSee Also:
-
getItemCountEstimate
int getItemCountEstimate()Gets the item count estimate. The default value depends on the component.
Returns:
item count estimate
See Also:
-
setItemCountEstimateIncrease
void setItemCountEstimateIncrease(int itemCountEstimateIncrease) Sets how much the item count estimate is increased once the previous item count estimate has been reached. Use this when the user should be able to scroll down faster. The default value depends on the component.
As an example, with an estimate of
1000
and an increase of500
, when scrolling down the item count will be:1000, 1500, 2000, 2500...
until the backend runs out of items.NOTE: the given increase should not be less than the
setPageSize(int)
set in the component, or there will be unnecessary backend requests.Parameters:
itemCountEstimateIncrease
- how much the item count estimate is increasedSee Also:
-
getItemCountEstimateIncrease
int getItemCountEstimateIncrease()Gets the item count estimate increase - how much the item count estimate is increased once the previous item count estimate has been reached. The default value depends on the component.
Returns:
the item count estimate increase
See Also:
-
setItemCountUnknown
void setItemCountUnknown()Switches the component to automatically extend the number of items as the previous end is almost reached. The component stops increasing the number of items once the backend has run out of items. Not getting the exact size of the backend upfront can improve performance with large sets of data.
The default initial item count and how much the item count is increased depends on the component. These values can be customized with
setItemCountEstimate(int)
andsetItemCountEstimateIncrease(int)
when the backend has a lot of items and faster scrolling down is desired. -
setItemIndexProvider
Sets the item index provider for this lazy data view. The provider is used to fetch the index of an item.
ItemIndexProvider.apply(Object, Query)
is called whenDataView.getItemIndex(Object)
is called. It gives an item and aQuery
as parameters. Query is prepared for fetching all items including filter and sorting.Parameters:
itemIndexProvider
- the item index provider to use
-