Class FormLayout.FormRow

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.formlayout.FormLayout.FormRow
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.HasStyle, Serializable
Enclosing class:
FormLayout

@Tag("vaadin-form-row") @NpmPackage(value="@vaadin/form-layout", version="25.0.0-beta1") @JsModule("@vaadin/form-layout/src/vaadin-form-row.js") public static class FormLayout.FormRow extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasComponents
Server-side component for the <vaadin-form-row> element. Used to arrange fields into rows inside a FormLayout when auto-responsive mode is enabled.

Each FormRow always starts on a new row. Fields that exceed the available columns wrap to a new row, which then remains reserved exclusively for the fields of that FormRow.

Example of creating a FormRow with two fields and a single field that spans two columns:

 FormLayout formLayout = new FormLayout();
 formLayout.setAutoResponsive(true);

 FormRow firstRow = new FormRow();
 firstRow.add(new TextField("First name"), new TextField("Last name"));

 FormRow secondRow = new FormRow();
 secondRow.add(new TextArea("Address"), 2); // colspan 2

 formLayout.add(firstRow, secondRow);
 
Author:
Vaadin Ltd
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty FormRow.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(com.vaadin.flow.component.Component component, int colspan)
    Adds a component with the desired colspan.
    addFormItem(com.vaadin.flow.component.Component field, com.vaadin.flow.component.Component label)
    Creates a new FormLayout.FormItem with the given field and label components and adds it to the form row.
    addFormItem(com.vaadin.flow.component.Component field, String label)
    Creates a new FormLayout.FormItem with the given component and the label string, and adds it to the form row.
    int
    getColspan(com.vaadin.flow.component.Component component)
    Gets the colspan of the given component.
    void
    setColspan(com.vaadin.flow.component.Component component, int colspan)
    Sets the colspan of the given component's element.

    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, onAttach, onDetach, 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.component.HasStyle

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

  • Method Details

    • add

      public void add(com.vaadin.flow.component.Component component, int colspan)
      Adds a component with the desired colspan. This method is a shorthand for calling HasComponents.add(Component...) and setColspan(Component, int)
      Parameters:
      component - the component to add
      colspan - the desired colspan for the component
    • setColspan

      public void setColspan(com.vaadin.flow.component.Component component, int colspan)
      Sets the colspan of the given component's element. Will default to 1 if an integer lower than 1 is supplied. You can directly add components with the wanted colspan with add(Component, int).
      Parameters:
      component - the component to set the colspan for, not null
      colspan - the desired colspan for the component
    • getColspan

      public int getColspan(com.vaadin.flow.component.Component component)
      Gets the colspan of the given component. If none is set, returns 1.
      Parameters:
      component - the component whose colspan is retrieved
      Returns:
      the colspan of the given component or 1 if none is set
    • addFormItem

      public FormLayout.FormItem addFormItem(com.vaadin.flow.component.Component field, String label)
      Creates a new FormLayout.FormItem with the given component and the label string, and adds it to the form row. The label is inserted into the form item as a NativeLabel.
      Parameters:
      field - the field component to be wrapped in a form item
      label - the label text to be displayed
      Returns:
      the created form item
    • addFormItem

      public FormLayout.FormItem addFormItem(com.vaadin.flow.component.Component field, com.vaadin.flow.component.Component label)
      Creates a new FormLayout.FormItem with the given field and label components and adds it to the form row.
      Parameters:
      field - the field component to be wrapped in a form item
      label - the label component to be displayed
      Returns:
      the created form item