Interface HasLazyDataView<T,F,V extends LazyDataView<T>>
- Type Parameters:
T
- item typeF
- filter typeV
- DataView type
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ComboBox
,ComboBoxBase
,CrudGrid
,Grid
,GridPro
,MultiSelectComboBox
,TreeGrid
LazyDataView
.- Since:
-
Method Summary
Modifier and TypeMethodDescriptionGet the LazyDataView for the component that allows access to the items in the component.setItems
(BackEndDataProvider<T, F> dataProvider) Supply items with aBackEndDataProvider
that lazy loads items from a backend.default V
setItems
(CallbackDataProvider.FetchCallback<T, F> fetchCallback) Supply items lazily with a callback from a backend.default V
setItems
(CallbackDataProvider.FetchCallback<T, F> fetchCallback, CallbackDataProvider.CountCallback<T, F> countCallback) Supply items lazily with callbacks: the first one fetches the items based on offset, limit and an optional filter, the second provides the exact count of items in the backend.
-
Method Details
-
setItems
Supply items lazily with a callback from a backend. The component will automatically fetch more items and adjust its size until the backend runs out of items. Usage example without component provided filter:component.setItems(query -> orderService.getOrders(query.getOffset(), query.getLimit());
If the component supports filtering, it can be fetched with query.getFilter().
The returned data view object can be used for further configuration, or later on fetched with
getLazyDataView()
. For using in-memory data, likeCollection
, useHasListDataView.setItems(Collection)
instead.- Parameters:
fetchCallback
- function that returns a stream of items from the backend based on the offset, limit and an optional filter provided by the query object- Returns:
- LazyDataView instance for further configuration
-
setItems
default V setItems(CallbackDataProvider.FetchCallback<T, F> fetchCallback, CallbackDataProvider.CountCallback<T, F> countCallback) Supply items lazily with callbacks: the first one fetches the items based on offset, limit and an optional filter, the second provides the exact count of items in the backend. Use this in case getting the count is cheap and the user benefits from the component showing immediately the exact size. Usage example without component provided filter:component.setItems( query -> orderService.getOrders(query.getOffset, query.getLimit()), query -> orderService.getSize());
If the component supports filtering, it can be fetched with query.getFilter().
The returned data view object can be used for further configuration, or later on fetched with
getLazyDataView()
. For using in-memory data, likeCollection
, useHasListDataView.setItems(Collection)
instead.- Parameters:
fetchCallback
- function that returns a stream of items from the back end for a querycountCallback
- function that return the number of items in the back end for a query- Returns:
- LazyDataView instance for further configuration
-
setItems
Supply items with aBackEndDataProvider
that lazy loads items from a backend. Note that component will query the data provider for the item count. In case that is not desired for performance reasons, usesetItems(CallbackDataProvider.FetchCallback)
instead.The returned data view object can be used for further configuration, or later on fetched with
getLazyDataView()
. For using in-memory data, likeCollection
, useHasListDataView.setItems(Collection)
instead.- Parameters:
dataProvider
- BackEndDataProvider instance- Returns:
- LazyDataView instance for further configuration
-
getLazyDataView
V getLazyDataView()Get the LazyDataView for the component that allows access to the items in the component. Throws an exception if the items are not provided lazily and another data view type should be used, likeListDataView
.- Returns:
- LazyDataView instance
- Throws:
IllegalStateException
- when lazy data view is not applicable
-