Class TableColumnGroup
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasComponentsOfType<TableColumn>,HasElement,HasEnabled,HasSize,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) Adds the given components as children of this component.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) Adds the given component as the first child of this component.voidaddComponentAtIndex(int index, TableColumn column) Adds the given component as a child of this component at the specific index.bindChildren(Signal<List<S>> list, 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) Replaces the component in the container with another one without changing position.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
Description copied from interface:HasComponentsOfTypeAdds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addin interfaceHasComponentsOfType<TableColumn>- Parameters:
columns- the components to add
-
addComponentAtIndex
Description copied from interface:HasComponentsOfTypeAdds the given component as a child of this component at the specific index.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addComponentAtIndexin interfaceHasComponentsOfType<TableColumn>- Parameters:
index- the index, where the component will be added. The index must be non-negative and may not exceed the children countcolumn- the component to add, value should not be null
-
addComponentAsFirst
Description copied from interface:HasComponentsOfTypeAdds the given component as the first child of this component.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addComponentAsFirstin interfaceHasComponentsOfType<TableColumn>- Parameters:
column- the component to add, value should not be null
-
replace
Description copied from interface:HasComponentsOfTypeReplaces the component in the container with another one without changing position. This method replaces a component with another one is such a way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If both components are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.- Specified by:
replacein interfaceHasComponentsOfType<TableColumn>- Parameters:
oldColumn- the old component that will be replaced. Can benull, which will make the newComponent to be added to the layout without replacing any othernewColumn- the new component to be replaced. Can benull, which will make the oldComponent to be removed from the layout without adding any other
-
bindChildren
public <V extends @Nullable Object,S extends Signal<V>> void bindChildren(Signal<List<S>> list, 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 interfaceHasComponentsOfType<TableColumn>- Type Parameters:
V- the value type of theSignals in the listS- the type of theSignals in the list- Parameters:
list- list signal to bind to the parent, must not benullchildFactory- factory to create new component, must not benull- 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.
-