A container widget which provides layout of children in a table grid. More...
#include <Wt/WTable>

Public Member Functions | |
| WTable (WContainerWidget *parent=0) | |
| Creates an empty table. | |
| virtual | ~WTable () |
| Deletes the table and its entire contents. | |
| WTableCell * | elementAt (int row, int column) |
| Accesses the table element at the given row and column. | |
| WTableRow * | rowAt (int row) |
| Returns the row object for the given row. | |
| WTableColumn * | columnAt (int column) |
| Returns the column object for the given column. | |
| void | removeCell (WTableCell *item) |
| Deletes a table cell and its contents. | |
| virtual void | removeCell (int row, int column) |
| Deletes the table cell at the given position. | |
| virtual WTableRow * | insertRow (int row, WTableRow *tableRow=0) |
| Inserts an empty row. | |
| virtual void | deleteRow (int row) |
| Deletes a row and all its contents. | |
| virtual WTableColumn * | insertColumn (int column, WTableColumn *tableColumn=0) |
| Inserts an empty column. | |
| virtual void | deleteColumn (int column) |
| Delete a column and all its contents. | |
| virtual void | clear () |
| Clears the entire table. | |
| int | rowCount () const |
| Returns the number of rows in the table. | |
| int | columnCount () const |
| Returns the number of columns in the table. | |
| void | setHeaderCount (int count, Orientation orientation=Horizontal) |
| Sets the number of header rows or columns. | |
| int | headerCount (Orientation orientation=Horizontal) |
| Returns the number of header rows or columns. | |
| virtual void | moveRow (int from, int to) |
| Move a table row from its original position to a new position. | |
| virtual void | moveColumn (int from, int to) |
| Move a table column from its original position to a new position. | |
Protected Member Functions | |
| virtual WTableCell * | createCell (int row, int column) |
| Creates a table cell. | |
| virtual WTableRow * | createRow (int row) |
| Creates a table row. | |
| virtual WTableColumn * | createColumn (int column) |
| Creates a table column. | |
A container widget which provides layout of children in a table grid.
A WTable arranges its children in a table.
To insert or access contents, use elementAt(int row, int column) 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.
Usage example:
Wt::WTable *table = new Wt::WTable(this); table->elementAt(0, 0)->addWidget(new Wt::WText("Item @ row 0, column 0")); table->elementAt(0, 1)->addWidget(new Wt::WText("Item @ row 0, column 1")); table->elementAt(1, 0)->addWidget(new Wt::WText("Item @ row 1, column 0")); table->elementAt(1, 1)->addWidget(new Wt::WText("Item @ row 1, column 1")); Wt::WTableCell *cell = table->elementAt(2, 0); cell->addWidget(new Wt::WText("Item @ row 2")); cell->setColumnSpan(2);
The widget corresponds to the HTML <table> tag and does not provide styling. It can be styled using inline or external CSS as appropriate.
| void Wt::WTable::clear | ( | ) | [virtual] |
Clears the entire table.
This method clears the entire table: all cells and their contents are deleted.
| WTableColumn * Wt::WTable::columnAt | ( | int | column | ) |
Returns the column object for the given column.
Like with elementAt(), the table expands automatically when the column is beyond the current table dimensions.
| WTableCell * Wt::WTable::createCell | ( | int | row, |
| int | column | ||
| ) | [protected, virtual] |
Creates a table cell.
You may want to override this method if you want your table to contain specialized cells.
| WTableColumn * Wt::WTable::createColumn | ( | int | column | ) | [protected, virtual] |
Creates a table column.
You may want to override this method if you want your table to contain specialized columns.
| WTableRow * Wt::WTable::createRow | ( | int | row | ) | [protected, virtual] |
Creates a table row.
You may want to override this method if you want your table to contain specialized rows.
| void Wt::WTable::deleteRow | ( | int | row | ) | [virtual] |
Deletes a row and all its contents.
Rows below the given row are shifted up.
| WTableCell * Wt::WTable::elementAt | ( | int | row, |
| int | column | ||
| ) |
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.
| int Wt::WTable::headerCount | ( | Orientation | orientation = Horizontal | ) |
Returns the number of header rows or columns.
| void Wt::WTable::moveColumn | ( | int | from, |
| int | to | ||
| ) | [virtual] |
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.
| void Wt::WTable::moveRow | ( | int | from, |
| int | to | ||
| ) | [virtual] |
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.
| void Wt::WTable::removeCell | ( | WTableCell * | item | ) |
Deletes a table cell and its contents.
The table cell at that position is recreated.
| void Wt::WTable::removeCell | ( | int | row, |
| int | column | ||
| ) | [virtual] |
Deletes the table cell at the given position.
| WTableRow * Wt::WTable::rowAt | ( | int | row | ) |
Returns the row object for the given row.
Like with elementAt(), the table expands automatically when the row is beyond the current table dimensions.
| void Wt::WTable::setHeaderCount | ( | int | count, |
| Orientation | orientation = Horizontal |
||
| ) |
Sets the number of header rows or columns.
The default values are 0.
1.7.6.1