Package com.vaadin.flow.component.html
Class TableRow
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.html.TableRow
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<TableRow>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponentsOfType<TableCell>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
@NullMarked
@Tag("tr")
public class TableRow
extends com.vaadin.flow.component.HtmlComponent
implements com.vaadin.flow.component.HasComponentsOfType<TableCell>, com.vaadin.flow.component.ClickNotifier<TableRow>
Component representing a
<tr> element — a row of a
Table.
A <tr> may only contain <td> and
<th> cells, which is what HasComponentsOfType
expresses: the standard add, remove, replace and
bindChildren operations are all available, but only for TableCell,
so anything else is rejected at compile time. What this class adds on top are
the cell factories, which create a cell and attach it in one call. To put
arbitrary content in a row, put it inside a cell.
- Since:
- 25.3
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTableRow()Creates a new empty row.TableRow(com.vaadin.flow.component.Component... components) Creates a new row with the given content, following the rules ofaddCells(Component...).List equivalent ofTableRow(Component...). -
Method Summary
Modifier and TypeMethodDescriptionaddCells(com.vaadin.flow.component.Component... components) Appends the given components to this row.List equivalent ofaddCells(Component...).Appends a header cell labelling the band of columns it heads, withscope="colgroup"set on the resulting<th>.addColumnGroupHeaderCell(String text, int colspan) Appends a header cell labelling the band of columns it heads, withscope="colgroup"and the givencolspanset on the resulting<th>, so that the cell reaches over the columns it names.addColumnHeaderCell(com.vaadin.flow.component.Component... content) Appends a header cell holding the given content and labelling the column it sits in, withscope="col"set on the resulting<th>.addColumnHeaderCell(String text) Appends a header cell labelling the column it sits in, withscope="col"set on the resulting<th>.addColumnHeaderCells(String... cellTexts) Appends a header cell for each of the given texts, each labelling the column it sits in withscope="col".addColumnHeaderCells(List<String> cellTexts) List equivalent ofaddColumnHeaderCells(String...).Appends a new empty data cell to this row.addDataCell(com.vaadin.flow.component.Component... content) Appends a new data cell holding the given content to this row, for a cell that is more than plain text.addDataCell(String text) Appends a new data cell with the given text to this row.addDataCells(String... cellTexts) Appends a sequence of data cells (<td>) with the given text contents to this row.addDataCells(List<String> cellTexts) List equivalent ofaddDataCells(String...).Appends a new empty header cell to this row.addHeaderCell(com.vaadin.flow.component.Component... content) Appends a new header cell holding the given content to this row, for a header that is more than plain text.addHeaderCell(String text) Appends a new header cell with the given text to this row.addHeaderCells(String... cellTexts) Appends a sequence of header cells (<th>) with the given text contents to this row.addHeaderCells(List<String> cellTexts) List equivalent ofaddHeaderCells(String...).addRowGroupHeaderCell(String text) Appends a header cell labelling the band of rows it heads, withscope="rowgroup"set on the resulting<th>.addRowGroupHeaderCell(String text, int rowspan) Appends a header cell labelling the band of rows it heads, withscope="rowgroup"and the givenrowspanset on the resulting<th>, so that the cell reaches over the rows it names.addRowHeaderCell(String text) Appends a header cell to this row that labels the row itself, withscope="row"set on the resulting<th>.getCells()Returns every cell of this row, in document order, both kinds combined.Returns the data cells of this row, in document order.Returns the header cells of this row, in document order.insertDataCell(int position) Inserts a new empty data cell at the given position.insertHeaderCell(int position) Inserts a new empty header cell at the given position.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
TableRow
public TableRow()Creates a new empty row. -
TableRow
public TableRow(com.vaadin.flow.component.Component... components) Creates a new row with the given content, following the rules ofaddCells(Component...).- Parameters:
components- the cells, or the content to wrap in cells.
-
TableRow
List equivalent ofTableRow(Component...).- Parameters:
components- the cells, or the content to wrap in cells.
-
-
Method Details
-
addCells
Appends the given components to this row. ATableCellis added as-is; anything else is wrapped in a newTableDataCell, since a<tr>may only contain cells. This is the lenient counterpart of the inheritedadd(TableCell...), which takes cells only and rejects anything else at compile time.- Parameters:
components- the cells, or the content to wrap in cells.- Returns:
- this row, for fluent chaining.
-
addCells
List equivalent ofaddCells(Component...).- Parameters:
components- the cells, or the content to wrap in cells.- Returns:
- this row, for fluent chaining.
-
addDataCells
Appends a sequence of data cells (<td>) with the given text contents to this row.- Parameters:
cellTexts- the text content for each data cell.- Returns:
- this row, for fluent chaining.
-
addDataCells
List equivalent ofaddDataCells(String...).- Parameters:
cellTexts- the text content for each data cell.- Returns:
- this row, for fluent chaining.
-
addHeaderCells
Appends a sequence of header cells (<th>) with the given text contents to this row.- Parameters:
cellTexts- the text content for each header cell.- Returns:
- this row, for fluent chaining.
-
addHeaderCells
List equivalent ofaddHeaderCells(String...).- Parameters:
cellTexts- the text content for each header cell.- Returns:
- this row, for fluent chaining.
-
addColumnHeaderCells
Appends a header cell for each of the given texts, each labelling the column it sits in withscope="col". This is the bulk form ofaddColumnHeaderCell(String)and the usual way to fill a row in aTableHead.- Parameters:
cellTexts- the text content of the cells, one cell per entry.- Returns:
- this row, for chaining.
-
addColumnHeaderCells
List equivalent ofaddColumnHeaderCells(String...).- Parameters:
cellTexts- the text content of the cells, one cell per entry.- Returns:
- this row, for chaining.
-
addHeaderCell
Appends a new empty header cell to this row.- Returns:
- the new
<th>.
-
addHeaderCell
Appends a new header cell with the given text to this row.- Parameters:
text- the text content.- Returns:
- the new
<th>.
-
addHeaderCell
Appends a new header cell holding the given content to this row, for a header that is more than plain text.- Parameters:
content- the content of the cell.- Returns:
- the new
<th>.
-
insertHeaderCell
Inserts a new empty header cell at the given position.- Parameters:
position- the position to insert the cell at, between 0 and the number of cells in this row.- Returns:
- the new
<th>.
-
addRowHeaderCell
Appends a header cell to this row that labels the row itself, withscope="row"set on the resulting<th>. This is a shortcut for the common pattern of using a leading<th>as a row label, which assistive technologies announce as the header for the data cells in the same row.- Parameters:
text- the text content.- Returns:
- the new
<th>withscope="row".
-
addColumnHeaderCell
Appends a header cell labelling the column it sits in, withscope="col"set on the resulting<th>. This is the counterpart ofaddRowHeaderCell(String)and the usual shape of a cell in aTableHead.- Parameters:
text- the text content.- Returns:
- the new
<th>withscope="col".
-
addColumnHeaderCell
Appends a header cell holding the given content and labelling the column it sits in, withscope="col"set on the resulting<th>.- Parameters:
content- the content of the cell.- Returns:
- the new
<th>withscope="col".
-
addRowGroupHeaderCell
Appends a header cell labelling the band of rows it heads, withscope="rowgroup"set on the resulting<th>. Use it for the cell that names a group of consecutive rows, such as "Terrestrial planets" in front of the four rows describing them, as opposed toaddRowHeaderCell(String), which labels one row.- Parameters:
text- the text content.- Returns:
- the new
<th>withscope="rowgroup".
-
addRowGroupHeaderCell
Appends a header cell labelling the band of rows it heads, withscope="rowgroup"and the givenrowspanset on the resulting<th>, so that the cell reaches over the rows it names.- Parameters:
text- the text content.rowspan- the number of rows the header covers, or0to cover the rest of the row group.- Returns:
- the new
<th>withscope="rowgroup". - Throws:
IllegalArgumentException- ifrowspanis negative.
-
addColumnGroupHeaderCell
Appends a header cell labelling the band of columns it heads, withscope="colgroup"set on the resulting<th>. This is the counterpart ofaddRowGroupHeaderCell(String), for a cell that names a group of consecutive columns rather than a single one.- Parameters:
text- the text content.- Returns:
- the new
<th>withscope="colgroup".
-
addColumnGroupHeaderCell
Appends a header cell labelling the band of columns it heads, withscope="colgroup"and the givencolspanset on the resulting<th>, so that the cell reaches over the columns it names.- Parameters:
text- the text content.colspan- the number of columns the header covers.- Returns:
- the new
<th>withscope="colgroup". - Throws:
IllegalArgumentException- ifcolspanis less than 1.
-
addDataCell
Appends a new empty data cell to this row.- Returns:
- the new
<td>.
-
addDataCell
Appends a new data cell with the given text to this row.- Parameters:
text- the text content.- Returns:
- the new
<td>.
-
addDataCell
Appends a new data cell holding the given content to this row, for a cell that is more than plain text.- Parameters:
content- the content of the cell.- Returns:
- the new
<td>.
-
insertDataCell
Inserts a new empty data cell at the given position.- Parameters:
position- the position to insert the cell at, between 0 and the number of cells in this row.- Returns:
- the new
<td>.
-
getHeaderCells
Returns the header cells of this row, in document order.- Returns:
- this row's
<th>cells.
-
getDataCells
Returns the data cells of this row, in document order.- Returns:
- this row's
<td>cells.
-
getCells
Returns every cell of this row, in document order, both kinds combined. This is the typed counterpart ofComponent.getChildren(). For kind-specific lists usegetHeaderCells()orgetDataCells().- Returns:
- this row's cells.
-