com.vaadin.flow.component.virtuallist.
Class VirtualList<T>
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.flow.component.virtuallist.VirtualList<T>
-
Type Parameters:
T
- the type of the items supported by the listAll Implemented Interfaces:
AttachNotifier, BlurNotifier<VirtualList<T>>, DetachNotifier, Focusable<VirtualList<T>>, FocusNotifier<VirtualList<T>>, HasElement, HasEnabled, HasSize, HasStyle, HasDataProvider<T>, HasItems<T>, Serializable
@Tag(value="vaadin-virtual-list") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="22.1.0") @NpmPackage(value="@vaadin/virtual-list",version="22.1.0") @NpmPackage(value="@vaadin/vaadin-virtual-list",version="22.1.0") @JsModule(value="@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule(value="@vaadin/polymer-legacy-adapter/template-renderer.js") @JsModule(value="@vaadin/virtual-list/vaadin-virtual-list.js") @JsModule(value="./flow-component-renderer.js") @JsModule(value="./virtualListConnector.js") public class VirtualList<T> extends Component implements HasDataProvider<T>, HasStyle, HasSize, Focusable<VirtualList<T>>
Component that encapsulates the functionality of the
<vaadin-virtual-list>
web component.It supports
DataProvider
s to load data asynchronously andRenderer
s to render the markup for each item.Author:
Vaadin Ltd.
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>
-
-
Constructor Summary
Constructors Constructor and Description VirtualList()
Creates an empty list.
-
Method Summary
All Methods Modifier and Type Method and Description DataCommunicator<T>
getDataCommunicator()
Returns the data communicator of this list.
DataProvider<T,?>
getDataProvider()
Returns the data provider of this list.
T
getPlaceholderItem()
Gets the placeholder item of this list, or
null
if none has been set.void
onEnabledStateChanged(boolean enabled)
Handle component enable state when the enabled state changes.
void
setDataProvider(DataProvider<T,?> dataProvider)
Sets the data provider for this listing.
void
setPlaceholderItem(T placeholderItem)
Sets an item to be shown as placeholder in the list while the real data in being fetched from the server.
void
setRenderer(Renderer<T> renderer)
Sets a renderer for the items in the list.
void
setRenderer(ValueProvider<T,String> valueProvider)
Sets a renderer for the items in the list, by using a
ValueProvider
.-
Methods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, set, setElement, setId, setVisible
-
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.binder.HasDataProvider
setItems
-
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Methods inherited from interface com.vaadin.flow.component.HasSize
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
-
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
-
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
-
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
-
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
-
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
-
-
-
Method Detail
-
setDataProvider
public void setDataProvider(DataProvider<T,?> dataProvider)
Description copied from interface:
HasDataProvider
Sets the data provider for this listing. The data provider is queried for displayed items as needed.
Specified by:
setDataProvider
in interfaceHasDataProvider<T>
Parameters:
dataProvider
- the data provider, not null
-
getDataProvider
public DataProvider<T,?> getDataProvider()
Returns the data provider of this list.
Returns:
the data provider of this list, not
null
-
getDataCommunicator
public DataCommunicator<T> getDataCommunicator()
Returns the data communicator of this list.
Returns:
the data communicator, not
null
-
setRenderer
public void setRenderer(ValueProvider<T,String> valueProvider)
Sets a renderer for the items in the list, by using a
ValueProvider
. The String returned by the provider is used to render each item.Parameters:
valueProvider
- a provider for the label string for each item in the list, notnull
-
setRenderer
public void setRenderer(Renderer<T> renderer)
Sets a renderer for the items in the list.
When set, a same renderer is used for the placeholder item. See
setPlaceholderItem(Object)
for details.Parameters:
renderer
- a renderer for the items in the list, notnull
-
setPlaceholderItem
public void setPlaceholderItem(T placeholderItem)
Sets an item to be shown as placeholder in the list while the real data in being fetched from the server.
Setting a placeholder item improves the user experience of the list while scrolling, since the placeholder uses the same renderer set with
setRenderer(Renderer)
, maintaining the same height for placeholders and actual items.When no placeholder item is set (or when set to
null
), an empty placeholder element is created with100px
of width and18px
of height.Note: when using
ComponentRenderer
s, the component used for the placeholder is statically stamped in the list. It can not be modified, nor receives any events.Parameters:
placeholderItem
- the item used as placeholder in the list, while the real data is being fetched from the server
-
getPlaceholderItem
public T getPlaceholderItem()
Gets the placeholder item of this list, or
null
if none has been set.Returns:
the placeholder item
-
onEnabledStateChanged
public void onEnabledStateChanged(boolean enabled)
Description copied from class:
Component
Handle component enable state when the enabled state changes.
By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.
Overrides:
onEnabledStateChanged
in classComponent
Parameters:
enabled
- the new enabled state of the component
-
-