Class TableColumnGroup
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponentsOfType<TableColumn>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,TableColumnSpan,Serializable
<colgroup> element — a group of
columns inside a Table, used to apply attributes (most often a class
for CSS) to several columns at once. Only a limited subset of CSS applies to
column groups: background, border (with
border-collapse: collapse), visibility: collapse and
width.
Per the WHATWG
HTML specification, a <colgroup> is used in one of two modes:
either it carries a span attribute and has no children, or it
contains zero or more <col> children and has no span
attribute. This component enforces that: adding a column to a group that
carries a span throws, as does setting a span on a group that
already has columns. Call TableColumnSpan.resetSpan() or HasComponentsOfType.removeAll() first
to switch a group from one mode to the other. <colgroup> elements
must be placed after the optional <caption> and before any
<thead>, <tbody>, <tfoot> or <tr>;
Table inserts them at the correct position automatically.
- Since:
- 25.3
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty column group.TableColumnGroup(TableColumn... columns) Creates a new column group with the given columns appended.TableColumnGroup(List<? extends TableColumn> columns) List equivalent ofTableColumnGroup(TableColumn...). -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Collection<TableColumn> columns) Appends a new empty<col>child to this group.addColumn(int span) Appends a new<col>child with the given span to this group.voidaddComponentAsFirst(TableColumn column) voidaddComponentAtIndex(int index, TableColumn column) <V extends @Nullable Object,S extends com.vaadin.flow.signals.Signal<V>>
voidbindChildren(com.vaadin.flow.signals.Signal<List<S>> list, com.vaadin.flow.function.SerializableFunction<S, TableColumn> childFactory) Not supported.Returns the columns inside this group.insertColumn(int position) Creates a new empty<col>and inserts it at the given position in this group.voidreplace(TableColumn oldColumn, TableColumn newColumn) voidsetSpan(int span) Sets thespanattribute — how many consecutive columns this element covers.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.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
add, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAllMethods 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, setClassNameMethods inherited from interface com.vaadin.flow.component.html.TableColumnSpan
getSpan, hasSpan, resetSpan
-
Constructor Details
-
TableColumnGroup
public TableColumnGroup()Creates a new empty column group. -
TableColumnGroup
Creates a new column group with the given columns appended.- Parameters:
columns- the columns to add.
-
TableColumnGroup
List equivalent ofTableColumnGroup(TableColumn...).- Parameters:
columns- the columns to add.
-
-
Method Details
-
addColumn
Appends a new empty<col>child to this group.- Returns:
- the new column.
-
addColumn
Appends a new<col>child with the given span to this group.- Parameters:
span- the number of columns to span.- Returns:
- the new column.
-
insertColumn
Creates a new empty<col>and inserts it at the given position in this group. This is the counterpart ofaddColumn(), matchinginsertRow,insertHeaderCellandinsertDataCellelsewhere in the family.- Parameters:
position- the position to insert the column at, between 0 and the number of columns in this group.- Returns:
- the new column.
- Throws:
IllegalStateException- if this group carries aspan, which a<colgroup>may not do alongside<col>children. CallTableColumnSpan.resetSpan()first.
-
getColumns
Returns the columns inside this group.- Returns:
- the list of
<col>children.
-
add
- Specified by:
addin interfacecom.vaadin.flow.component.HasComponentsOfType<TableColumn>
-
addComponentAtIndex
- Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponentsOfType<TableColumn>
-
addComponentAsFirst
- Specified by:
addComponentAsFirstin interfacecom.vaadin.flow.component.HasComponentsOfType<TableColumn>
-
replace
- Specified by:
replacein interfacecom.vaadin.flow.component.HasComponentsOfType<TableColumn>
-
bindChildren
public <V extends @Nullable Object,S extends com.vaadin.flow.signals.Signal<V>> void bindChildren(com.vaadin.flow.signals.Signal<List<S>> list, com.vaadin.flow.function.SerializableFunction<S, TableColumn> childFactory) Not supported. The columns of a<colgroup>are structure rather than data, and a binding would attach them straight to the element, bypassing the check that keepsspanand<col>children mutually exclusive. Bind the rows of aTableBodyinstead.- Specified by:
bindChildrenin interfacecom.vaadin.flow.component.HasComponentsOfType<TableColumn>- Throws:
UnsupportedOperationException- always.
-
setSpan
public void setSpan(int span) Sets thespanattribute — how many consecutive columns this element covers. The default is1. Use it to apply the same styling or attributes across a range of columns without writing one element per column.A
<colgroup>carrying aspanmay not also have<col>children, so this refuses a group that already has some.- Specified by:
setSpanin interfaceTableColumnSpan- Parameters:
span- a positive integer.- Throws:
IllegalStateException- if this group has<col>children. CallHasComponentsOfType.removeAll()first.
-