Class GridLazyDataView<T>
- Type Parameters:
T
- the type of the items in grid
- All Implemented Interfaces:
DataView<T>
,LazyDataView<T>
,Serializable
- 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
ConstructorDescriptionGridLazyDataView
(DataCommunicator<T> dataCommunicator, Grid<T> component) Creates a new lazy data view for grid and verifies the passed data provider is compatible with this data view implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets a callback that the Grid uses to get the exact item count in the backend.void
setItemCountEstimate
(int itemCountEstimate) Sets the estimated item count for the component.void
Switches the component to get the exact item count from the data provider'sDataProvider.size(Query)
.void
Switches the component to automatically extend the number of items as the previous end is almost reached.Methods inherited from class com.vaadin.flow.data.provider.AbstractLazyDataView
getDataCommunicator, getItem, getItemCountEstimate, getItemCountEstimateIncrease, getItems, getSupportedDataProviderType, setItemCountEstimateIncrease
Methods inherited from class com.vaadin.flow.data.provider.AbstractDataView
addIdentifierProviderChangeListener, addItemCountChangeListener, equals, getIdentifierProvider, refreshAll, refreshItem, setIdentifierProvider, verifyDataProviderType
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.DataView
addItemCountChangeListener, refreshAll, refreshItem, setIdentifierProvider
-
Constructor Details
-
GridLazyDataView
Creates a new lazy data view for grid and verifies the passed data provider is compatible with this data view implementation.- Parameters:
dataCommunicator
- the data communicator of the componentcomponent
- the grid
-
-
Method Details
-
setItemCountCallback
Sets a callback that the Grid uses to get the exact item count in the backend. Use this when it is cheap to get the exact item count and it is desired that the user sees the "full scrollbar size".The given callback will be queried for the count instead of the data provider
DataProvider.size(Query)
method when the component has a distinct data provider set withHasLazyDataView.setItems(BackEndDataProvider)
.- Parameters:
callback
- the callback to use for determining item count in the backend, notnull
- See Also:
-
setItemCountFromDataProvider
public void setItemCountFromDataProvider()Switches the component to get the exact item count from the data provider'sDataProvider.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".Calling this method will clear any previously set count callback with the
setItemCountCallback(CallbackDataProvider.CountCallback)
method.- Specified by:
setItemCountFromDataProvider
in interfaceLazyDataView<T>
- Overrides:
setItemCountFromDataProvider
in classAbstractLazyDataView<T>
-
setItemCountEstimate
public 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.Calling this method will clear any previously set count callback
setItemCountCallback(CallbackDataProvider.CountCallback)
.- Specified by:
setItemCountEstimate
in interfaceLazyDataView<T>
- Overrides:
setItemCountEstimate
in classAbstractLazyDataView<T>
- Parameters:
itemCountEstimate
- estimated item count of the backend- See Also:
-
setItemCountUnknown
public 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
LazyDataView.setItemCountEstimate(int)
andLazyDataView.setItemCountEstimateIncrease(int)
when the backend has a lot of items and faster scrolling down is desired.Calling this method will clear any previously set count callback
setItemCountCallback(CallbackDataProvider.CountCallback)
.- Specified by:
setItemCountUnknown
in interfaceLazyDataView<T>
- Overrides:
setItemCountUnknown
in classAbstractLazyDataView<T>
-