Class Table
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
org.vaadin.firitin.fields.internalhtmltable.Table
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasSize
,com.vaadin.flow.component.HasStyle
,Serializable
,TableRowContainer
@Tag("table")
public class Table
extends com.vaadin.flow.component.HtmlComponent
implements TableRowContainer
Represents the html table element (
Sub elements except for rows are created when calling the respective getter, for instance
Also a table must not contain rows as direct children, when having a
Also all subsequent calls to any table row method are automatically delegated to the
<table>
). Can contain
- a caption
- a column group
- a thead
- a tfoot
- a tbody or a set of table rows
Sub elements except for rows are created when calling the respective getter, for instance
getHead()
. Since
<table>
expects a certain order of elements, this class takes care of positioning them in the correct
order (e.g. head <thead>
, then <tbody>
and then <tfoot>
, etc).
Also a table must not contain rows as direct children, when having a
<tbody>
. Therefore, all previously to the
table assigned rows are automatically assigned to the <tbody>
, when getBody()
is called.
Also all subsequent calls to any table row method are automatically delegated to the
<tbody>
.- Author:
- Stefan Uebe
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddRow()
Adds a single row instance to this container.TableRow[]
addRows
(int rows) Adds multiple rows to this instance based on the given integer (must be greater than 0).void
Adds the given list of rows.getBody()
Returns theTableBody
for this instance.Returns theTableCaption
for this instance.Returns theTableColumnGroup
for this instance.getFoot()
Returns theTableFoot
for this instance.getHead()
Returns theTableHead
for this instance.insertRow
(int index) Inserts a single row instance at the given index to this container.void
insertRows
(int index, TableRow... rows) Inserts the given rows at the given index to this instance.void
Removes all rows.void
Removes the body instance from this table.void
Removes the caption instance from this table.void
Removes the column group instance from this table.void
Removes the foot instance from this table.void
Removes the head instance from this table.void
removeRow
(int index) Removes the row with the given index.void
removeRows
(TableRow... rows) Removes the given rows from this instance.void
replaceRow
(int index, TableRow row) Replaces a single row instance to the given index in this container and replaces the existing row.void
Replaces a single row instance to the given index in this container and replaces the existing row.Returns the rows of this instance as a stream.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitle
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.HasElement
getElement
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
Methods inherited from interface org.vaadin.firitin.fields.internalhtmltable.TableRowContainer
getChildren, getRow, getRows
-
Constructor Details
-
Table
public Table()
-
-
Method Details
-
getCaption
Returns theTableCaption
for this instance. Creates a new instance on the first call.- Returns:
- caption
-
getColumnGroup
Returns theTableColumnGroup
for this instance. Creates a new instance on the first call.- Returns:
- column group
-
getHead
Returns theTableHead
for this instance. Creates a new instance on the first call.- Returns:
- table head
-
removeHead
public void removeHead()Removes the head instance from this table.
Does not move any rows from the head to the table itself. That has to be done manually. -
removeFoot
public void removeFoot()Removes the foot instance from this table.
Does not move any rows from the foot to the table itself. That has to be done manually. -
removeBody
public void removeBody()Removes the body instance from this table.
Does not move any rows from the body to the table itself. That has to be done manually. -
removeCaption
public void removeCaption()Removes the caption instance from this table. -
removeColumnGroup
public void removeColumnGroup()Removes the column group instance from this table. -
getBody
Returns theTableBody
for this instance. Creates a new instance on the first call.
When rows have been assigned to this table instance before calling this method, these rows will be reassigned to the body to prevent creating an invalid dom structure.
Any subsequent calls to this table'saddRows(TableRow...)
method will be delegated to the body's one.- Returns:
- table body
-
getFoot
Returns theTableFoot
for this instance. Creates a new instance on the first call.- Returns:
- foot
-
addRows
Adds the given list of rows.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
addRows
in interfaceTableRowContainer
- Parameters:
rows
- rows
-
insertRows
Inserts the given rows at the given index to this instance. Existing items will be placed after the inserted items.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
insertRows
in interfaceTableRowContainer
- Parameters:
rows
- rowsindex
- to insert the rows at
-
replaceRow
Replaces a single row instance to the given index in this container and replaces the existing row.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
replaceRow
in interfaceTableRowContainer
- Parameters:
index
- index to set the new item torow
- row
-
removeRows
Removes the given rows from this instance. Items, that are not child of this instance, will lead to an exception.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
removeRows
in interfaceTableRowContainer
- Parameters:
rows
- rows to remove
-
streamRows
Returns the rows of this instance as a stream. Empty if no rows have been added yet.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
streamRows
in interfaceTableRowContainer
- Returns:
- rows as stream
-
addRow
Adds a single row instance to this container. The created row is returned for further configuration.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
addRow
in interfaceTableRowContainer
- Returns:
- the created row
-
addRows
Adds multiple rows to this instance based on the given integer (must be greater than 0). The created rows are returned as an array, that can be used for further configuration.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
addRows
in interfaceTableRowContainer
- Parameters:
rows
- amount of rows to add- Returns:
- created row objects
-
insertRow
Inserts a single row instance at the given index to this container. Existing items will be placed after the inserted items. The created row is returned for further configuration.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
insertRow
in interfaceTableRowContainer
- Parameters:
index
- to insert the row at- Returns:
- the created row
-
setRow
Replaces a single row instance to the given index in this container and replaces the existing row.
This method has the same functionality asreplaceRow(int, TableRow)
.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
setRow
in interfaceTableRowContainer
- Parameters:
index
- index to set the new item torow
- row- See Also:
-
removeAllRows
public void removeAllRows()Removes all rows.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
removeAllRows
in interfaceTableRowContainer
-
removeRow
public void removeRow(int index) Removes the row with the given index. Noop, if no row has been found for that index.
When this table has a body, it will automatically delegate the call to the body's respective method.- Specified by:
removeRow
in interfaceTableRowContainer
- Parameters:
index
- index to remove
-