Class WTable
A WTable arranges its children in a table.
To insert or access contents, use getElementAt()
to access the cell
at a particular location in the table. The
WTable expands automatically to create the indexed (row, column) as necessary.
It is possible to insert and delete entire rows or columns from the table using the insertColumn(int column), insertRow(int row), deleteColumn(int column), or deleteRow(int row) methods.
You may indicate a number of rows and columns that act as headers using setHeaderCount()
. Header cells are
rendered as <th>
instead of <td>
elements. By default, no
rows or columns are configured as headers.
WTable is displayed as a block
.
CSS
The widget corresponds to the HTML <table>
tag and does not provide
styling. It can be styled using inline or external CSS as appropriate.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
ConstructorDescriptionWTable()
Creates an empty table.WTable
(WContainerWidget parentContainer) Creates an empty table. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the entire table.protected WTableCell
createCell
(int row, int column) Creates a table cell.protected WTableColumn
createColumn
(int column) Creates a table column.protected DomElement
Create DOM element for widget.protected WTableRow
createRow
(int row) Creates a table row.getColumnAt
(int column) Returns the column object for the given column.int
Returns the number of columns in the table.protected void
getDomChanges
(List<DomElement> result, WApplication app) Get DOM changes for this widget.getElementAt
(int row, int column) Accesses the table element at the given row and column.final int
Returns the number of header rows or columns.int
getHeaderCount
(Orientation orientation) Returns the number of header rows or columns.getRowAt
(int row) Returns the row object for the given row.int
Returns the number of rows in the table.final WTableColumn
insertColumn
(int column) Inserts an empty column.insertColumn
(int column, WTableColumn tableColumn) Inserts an empty column.final WTableRow
insertRow
(int row) Inserts a row.Inserts a row.protected void
iterateChildren
(HandleWidgetMethod method) void
moveColumn
(int from, int to) Move a table column from its original position to a new position.void
moveRow
(int from, int to) Move a table row from its original position to a new position.void
remove()
Deletes the table and its entire contents.void
removeCell
(int row, int column) Deletes the table cell at the given position.void
removeCell
(WTableCell item) Deletes a table cell and its contents.removeColumn
(int column) Remove a column and all its contents.removeRow
(int row) Removes a row.final void
setHeaderCount
(int count) Sets the number of header rows or columns.void
setHeaderCount
(int count, Orientation orientation) Sets the number of header rows or columns.Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, doJavaScript, enableAjax, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, refresh, removeScript, removeStyleClass, render, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName, setFormData
-
Constructor Details
-
WTable
Creates an empty table. -
WTable
public WTable()Creates an empty table.
-
-
Method Details
-
remove
public void remove()Deletes the table and its entire contents.- Overrides:
remove
in classWInteractWidget
- See Also:
-
getElementAt
Accesses the table element at the given row and column.If the row/column is beyond the current table dimensions, then the table is expanded automatically.
-
getRowAt
Returns the row object for the given row.Like with
getElementAt()
, the table expands automatically when the row is beyond the current table dimensions. -
getColumnAt
Returns the column object for the given column.Like with
getElementAt()
, the table expands automatically when the column is beyond the current table dimensions. -
removeCell
Deletes a table cell and its contents.The table cell at that position is recreated.
- See Also:
-
removeCell
public void removeCell(int row, int column) Deletes the table cell at the given position.- See Also:
-
insertRow
Inserts a row. -
insertRow
Inserts a row.Returns
insertRow(row, null)
-
removeRow
Removes a row.Rows below the given row are shifted up. Returns a
WTableRow
that is not associated with aWTable
. UnlinkeremoveColumn()
, the cells in the row will not be deleted, because they are owned by theWTableRow
. -
insertColumn
Inserts an empty column. -
insertColumn
Inserts an empty column.Returns
insertColumn(column, null)
-
removeColumn
Remove a column and all its contents.The contents of the column will be deleted, because a
WTableColumn
does not own its cells. -
clear
public void clear()Clears the entire table.This method clears the entire table: all cells and their contents are deleted.
-
getRowCount
public int getRowCount()Returns the number of rows in the table. -
getColumnCount
public int getColumnCount()Returns the number of columns in the table. -
setHeaderCount
Sets the number of header rows or columns.The default values are 0.
Note: This must be set before the initial rendering and cannot be changed later.
-
setHeaderCount
public final void setHeaderCount(int count) Sets the number of header rows or columns. -
getHeaderCount
Returns the number of header rows or columns. -
getHeaderCount
public final int getHeaderCount()Returns the number of header rows or columns. -
moveRow
public void moveRow(int from, int to) Move a table row from its original position to a new position.The table expands automatically when the
to
row is beyond the current table dimensions.- See Also:
-
moveColumn
public void moveColumn(int from, int to) Move a table column from its original position to a new position.The table expands automatically when the
to
column is beyond the current table dimensions.- See Also:
-
createCell
Creates a table cell.You may want to override this method if you want your table to contain specialized cells.
-
createRow
Creates a table row.You may want to override this method if you want your table to contain specialized rows.
-
createColumn
Creates a table column.You may want to override this method if you want your table to contain specialized columns.
-
createDomElement
Description copied from class:WWebWidget
Create DOM element for widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
createDomElement
in classWWebWidget
-
getDomChanges
Description copied from class:WWebWidget
Get DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChanges
in classWWebWidget
-
iterateChildren
- Overrides:
iterateChildren
in classWWebWidget
-