Class FormLayout.FormRow
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.formlayout.FormLayout.FormRow
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasComponents
,HasElement
,HasEnabled
,HasStyle
,Serializable
- Enclosing class:
- FormLayout
@Tag("vaadin-form-row")
@NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.8.2") @NpmPackage(value="@vaadin/form-layout",version="24.8.2")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/form-layout/src/vaadin-form-row.js")
public static class FormLayout.FormRow
extends Component
implements 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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a component with the desired colspan.addFormItem
(Component field, Component label) Creates a newFormLayout.FormItem
with the given field and label components and adds it to the form row.addFormItem
(Component field, String label) Creates a newFormLayout.FormItem
with the given component and the label string, and adds it to the form row.int
getColspan
(Component component) Gets the colspan of the given component.void
setColspan
(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
-
FormRow
public FormRow()Constructs an empty FormRow. Components to wrap can be added after construction withHasComponents.add(Component...)
, or by using theaddFormItem(Component, String)
andaddFormItem(Component, Component)
methods.- See Also:
-
-
Method Details
-
add
Adds a component with the desired colspan. This method is a shorthand for callingHasComponents.add(Component...)
andsetColspan(Component, int)
- Parameters:
component
- the component to addcolspan
- the desired colspan for the component
-
setColspan
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 withadd(Component, int)
.- Parameters:
component
- the component to set the colspan for, notnull
colspan
- the desired colspan for the component
-
getColspan
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
Creates a newFormLayout.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 aNativeLabel
.- Parameters:
field
- the field component to be wrapped in a form itemlabel
- the label text to be displayed- Returns:
- the created form item
-
addFormItem
Creates a newFormLayout.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 itemlabel
- the label component to be displayed- Returns:
- the created form item
-