Class JmixGridLayout<T>

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.flowui.kit.component.gridlayout.JmixGridLayout<T>
Type Parameters:
T - the type of the items displayed in this layout
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.data.binder.HasItemComponents<T>, com.vaadin.flow.data.provider.HasDataView<T,Void,GridLayoutDataView<T>>, com.vaadin.flow.data.provider.HasListDataView<T,GridLayoutListDataView<T>>, Serializable
Direct Known Subclasses:
GridLayout

@Tag("jmix-grid-layout") @JsModule("./src/grid-layout/jmix-grid-layout.js") public class JmixGridLayout<T> extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize, com.vaadin.flow.data.binder.HasItemComponents<T>, com.vaadin.flow.data.provider.HasListDataView<T,GridLayoutListDataView<T>>, com.vaadin.flow.data.provider.HasDataView<T,Void,GridLayoutDataView<T>>
Represents a customizable grid layout component for displaying data in a grid-based format.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.data.binder.HasItemComponents

    com.vaadin.flow.data.binder.HasItemComponents.ItemComponent<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     
    protected final AtomicReference<com.vaadin.flow.data.provider.DataProvider<T,?>>
     
    protected com.vaadin.flow.shared.Registration
     
    protected com.vaadin.flow.component.ItemLabelGenerator<T>
     
    protected com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T>
     
    protected List<T>
     
    protected static final String
     
    protected int
     
    protected int
     
    protected com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected GridLayoutItem<T>
     
    protected void
     
    getAlignSelf(com.vaadin.flow.component.HasElement component)
    Returns the individual alignment of a given component inside a cell along the block (column) axis.
    Returns the minimum width of the columns in the JmixGridLayout.
    com.vaadin.flow.data.provider.DataProvider<T,?>
    Gets the data provider used by this JmixGridLayout.
    Returns the gap of the grid layout in the JmixGridLayout.
    Gets the generic data view for the JmixGridLayout.
    protected List<GridLayoutItem<T>>
     
    protected Object
    getItemId(T item)
     
    com.vaadin.flow.component.ItemLabelGenerator<T>
    Gets the item label generator used to produce the strings shown in the JmixGridLayout for each item.
    com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T>
    Returns the item component renderer.
    getJustifySelf(com.vaadin.flow.component.HasElement component)
    Returns the individual alignment of a given component inside a cell along the inline (row) axis.
    Gets the list data view for the JmixGridLayout.
    protected void
    handleDataChange(com.vaadin.flow.data.provider.DataChangeEvent<T> event)
     
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
     
    protected void
     
    protected void
    refresh(T item)
     
    protected void
    refreshContent(GridLayoutItem<T> gridLayoutItem)
     
    protected void
    runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)
     
    void
    setAlignSelf(Alignment alignment, com.vaadin.flow.component.HasElement... components)
    Sets an alignment for individual components inside their cells along the block (column) axis.
    void
    setColumnMinWidth(String columnMinWidth)
    Sets the minimum width for the grid columns in the JmixGridLayout.
    void
    setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
    Sets a generic data provider for the JmixGridLayout to use.
    void
    setGap(String gridGap)
    Sets the gap of the grid layout in the JmixGridLayout.
    void
    setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
     
    setItems(com.vaadin.flow.data.provider.DataProvider<T,Void> dataProvider)
    Sets a generic data provider for the JmixGridLayout to use and returns the base GridLayoutDataView that provides API to get information on the items.
    setItems(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider)
    Sets an in-memory data provider for the JmixGridLayout to use.
    setItems(com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
    Sets a ListDataProvider for the JmixGridLayout to use and returns a ListDataView that provides information and allows operation on the items.
    void
    setJustifySelf(Alignment alignment, com.vaadin.flow.component.HasElement... components)
    Sets an alignment for individual components inside their cells along the inline (row) axis.
    void
    setRenderer(com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T> itemRenderer)
    Sets the item renderer for this JmixGridLayout.
    protected void
    setupDataProviderListener(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
     

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, 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.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.data.binder.HasItemComponents

    addComponents, getItemPosition, prependComponents

    Methods inherited from interface com.vaadin.flow.data.provider.HasListDataView

    setItems, setItems

    Methods inherited from interface com.vaadin.flow.component.HasSize

    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.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Field Details

    • ALIGN_SELF_CSS_PROPERTY

      protected static final String ALIGN_SELF_CSS_PROPERTY
      See Also:
    • JUSTIFY_SELF_CSS_PROPERTY

      protected static final String JUSTIFY_SELF_CSS_PROPERTY
      See Also:
    • dataProvider

      protected final AtomicReference<com.vaadin.flow.data.provider.DataProvider<T,?>> dataProvider
    • items

      protected List<T> items
    • dataProviderListenerRegistration

      protected com.vaadin.flow.shared.Registration dataProviderListenerRegistration
    • itemLabelGenerator

      protected com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator
    • itemRenderer

      protected com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T> itemRenderer
    • lastNotifiedDataSize

      protected int lastNotifiedDataSize
    • lastFetchedDataSize

      protected volatile int lastFetchedDataSize
    • sizeRequest

      protected com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> sizeRequest
  • Constructor Details

    • JmixGridLayout

      public JmixGridLayout()
  • Method Details

    • getGap

      public String getGap()
      Returns the gap of the grid layout in the JmixGridLayout. Default value is var(--lumo-space-s).
      Returns:
      the gap of the grid layout
    • setGap

      public void setGap(String gridGap)
      Sets the gap of the grid layout in the JmixGridLayout.
      Parameters:
      gridGap - the gap to be set for the grid layout, represented as a CSS length value (e.g., "10px", "1rem")
    • getColumnMinWidth

      public String getColumnMinWidth()
      Returns the minimum width of the columns in the JmixGridLayout. Default value is 19rem
      Returns:
      the minimum width for the columns as a CSS length value (e.g., "19rem")
    • setColumnMinWidth

      public void setColumnMinWidth(String columnMinWidth)
      Sets the minimum width for the grid columns in the JmixGridLayout.
      Parameters:
      columnMinWidth - the minimum width to be set for the grid columns, represented as a CSS length value (e.g., "50px", "10rem")
    • getAlignSelf

      public Alignment getAlignSelf(com.vaadin.flow.component.HasElement component)
      Returns the individual alignment of a given component inside a cell along the block (column) axis.

      The default alignment for individual components is Alignment.AUTO.

      Parameters:
      component - the component which individual layout should be read
      Returns:
      the alignment of the component
    • setAlignSelf

      public void setAlignSelf(@Nullable Alignment alignment, com.vaadin.flow.component.HasElement... components)
      Sets an alignment for individual components inside their cells along the block (column) axis.

      It effectively sets the "alignSelf" style value.

      Parameters:
      alignment - the individual alignment for the children components. Setting null will reset the alignment to its default
      components - the components to which the individual alignment should be set
    • getJustifySelf

      public Alignment getJustifySelf(com.vaadin.flow.component.HasElement component)
      Returns the individual alignment of a given component inside a cell along the inline (row) axis.

      The default alignment for individual components is Alignment.AUTO.

      Parameters:
      component - the component which individual layout should be read
      Returns:
      the alignment of the component
    • setJustifySelf

      public void setJustifySelf(@Nullable Alignment alignment, com.vaadin.flow.component.HasElement... components)
      Sets an alignment for individual components inside their cells along the inline (row) axis.

      It effectively sets the "justifySelf" style value.

      Parameters:
      alignment - the individual alignment for the children components. Setting null will reset the alignment to its default
      components - the components to which the individual alignment should be set
    • getDataProvider

      public com.vaadin.flow.data.provider.DataProvider<T,?> getDataProvider()
      Gets the data provider used by this JmixGridLayout.

      To get information and control over the items in the JmixGridLayout, use either getListDataView() or getGenericDataView() instead.

      Returns:
      the data provider used by this JmixGridLayout
    • setDataProvider

      public void setDataProvider(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
      Sets a generic data provider for the JmixGridLayout to use.

      Use this method when none of the setItems methods are applicable, e.g., when having a data provider with a filter that cannot be transformed to DataProvider<T, Void>.

      Parameters:
      dataProvider - DataProvider instance to use, not null
    • setupDataProviderListener

      protected void setupDataProviderListener(com.vaadin.flow.data.provider.DataProvider<T,?> dataProvider)
    • handleDataChange

      protected void handleDataChange(com.vaadin.flow.data.provider.DataChangeEvent<T> event)
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • getItemRenderer

      public com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T> getItemRenderer()
      Returns the item component renderer.
      Returns:
      the item renderer
      See Also:
    • setRenderer

      public void setRenderer(com.vaadin.flow.data.renderer.ComponentRenderer<? extends com.vaadin.flow.component.Component,T> itemRenderer)
      Sets the item renderer for this JmixGridLayout. The renderer is applied to each item to create a component which represents the item.
      Parameters:
      itemRenderer - the item renderer, not null
    • getItemLabelGenerator

      public com.vaadin.flow.component.ItemLabelGenerator<T> getItemLabelGenerator()
      Gets the item label generator used to produce the strings shown in the JmixGridLayout for each item.
      Returns:
      the item label provider to use, not null
    • setItemLabelGenerator

      public void setItemLabelGenerator(com.vaadin.flow.component.ItemLabelGenerator<T> itemLabelGenerator)
    • rebuild

      protected void rebuild()
    • createItemComponent

      protected GridLayoutItem<T> createItemComponent(T item)
    • refresh

      protected void refresh(T item)
    • refreshContent

      protected void refreshContent(GridLayoutItem<T> gridLayoutItem)
    • getItemComponents

      protected List<GridLayoutItem<T>> getItemComponents()
    • setItems

      public GridLayoutDataView<T> setItems(com.vaadin.flow.data.provider.DataProvider<T,Void> dataProvider)
      Sets a generic data provider for the JmixGridLayout to use and returns the base GridLayoutDataView that provides API to get information on the items.

      This method should be used only when the data provider type is not either ListDataProvider or BackEndDataProvider.

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasDataView<T,Void,GridLayoutDataView<T>>
      Parameters:
      dataProvider - DataProvider instance to use, not null
      Returns:
      GridLayoutDataView providing information on the data
    • setItems

      public GridLayoutDataView<T> setItems(com.vaadin.flow.data.provider.InMemoryDataProvider<T> inMemoryDataProvider)
      Sets an in-memory data provider for the JmixGridLayout to use.

      Note! Using a ListDataProvider instead of a InMemoryDataProvider is recommended to get access to GridLayoutListDataView API by using HasListDataView.setItems(ListDataProvider).

      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasDataView<T,Void,GridLayoutDataView<T>>
      Parameters:
      inMemoryDataProvider - data provider to use, not null
      Returns:
      GridLayoutDataView providing information on the data
    • setItems

      public GridLayoutListDataView<T> setItems(com.vaadin.flow.data.provider.ListDataProvider<T> listDataProvider)
      Sets a ListDataProvider for the JmixGridLayout to use and returns a ListDataView that provides information and allows operation on the items.
      Specified by:
      setItems in interface com.vaadin.flow.data.provider.HasListDataView<T,GridLayoutListDataView<T>>
      Parameters:
      listDataProvider - ListDataProvider providing items to the JmixGridLayout.
      Returns:
      GridLayoutListDataView providing access to the items
    • getListDataView

      public GridLayoutListDataView<T> getListDataView()
      Gets the list data view for the JmixGridLayout. This data view should only be used when the items are in-memory and set with: If the items are not in-memory, an exception is thrown.
      Specified by:
      getListDataView in interface com.vaadin.flow.data.provider.HasListDataView<T,GridLayoutListDataView<T>>
      Returns:
      the list data view that provides access to the data bound to the JmixGridLayout
    • getGenericDataView

      public GridLayoutDataView<T> getGenericDataView()
      Gets the generic data view for the JmixGridLayout. This data view should only be used when getListDataView() is not applicable for the underlying data provider.
      Specified by:
      getGenericDataView in interface com.vaadin.flow.data.provider.HasDataView<T,Void,GridLayoutDataView<T>>
      Returns:
      the generic DataView instance implementing GridLayoutDataView
    • getItemId

      protected Object getItemId(T item)
    • fireSizeEvent

      protected void fireSizeEvent()
    • runBeforeClientResponse

      protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)