TKTable Class Reference
[Containers]

Represents a basic HTML table. More...

Inheritance diagram for TKTable:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 __construct ($autoFirstRow=true)
 Creates new table.
 addData ($data)
 Adds a 2d array of data to the table.
 addRow ($id="", $class="")
 Adds a new row to the table.
 getRowId ($rowIdx)
 Retrieves row ID associated with given row.


Detailed Description

Represents a basic HTML table.

The table does not support cells spanning multiple rows and columns. For that, use https:://wiki.shodor.org/index.php/TKAdvTable. The table has two slots, one for the header cells and one for everything else (but see note below). Header cells have a different CSS class and style than normal cells. As you add components as normal cells, they will fill one run. The add new rows, call addRow() and then new components will go in a new row. If you want to access old rows, add components to specific row slots, which are named 'rowX', where X is a number from 0 to one less than the number of rows.

When building a table from XML, use the <row /> tag to create a new row. It is self-closing.

If you add text with TKContainer::addText, you can add a 'style' or 'class' parameter, which is applied to the cell that contains the text. These parameters are themselves arrays, following the normal rules for style and class arrays.

The basic usage of TKTable is to first add some cells to the header slot. Since these are almost always going to be text instead of another component, it is best to use the TKContainer::addTextTo method. For example, to build a header for four columns do the following:

      $table->addTextTo('header', "Column 1");
      $table->addTextTo('header', "Column 2");
      $table->addTextTo('header', "Column 3");
      // this header spans two columns
      $table->addTextTo('header', "Wide Column 4", array('colspan' => 2));
  

The table starts with a row already, so the first components added without specifying a slot go in this first row, from right to left. You will need to call addRow() for additional rows after that. Below is an example of constructing a table with two rows and three columns:

      $table->addText('Cell (0,0)');
      $table->addText('Cell (0,1)');
      $table->addText('Cell (0,2)');
      $table->addRow();
      $table->addText('Cell (1,0)');
      $table->addText('Cell (1,1)');
      $table->addText('Cell (1,2)');
  

Properties:
  • cell_class array: CSS class for cells
  • cell_style array: CSS style for cells
  • header_class array: CSS class for header cells
  • header_style array: CSS style for header cells
  • footer_class array: CSS class for footer cells
  • footer_style array: CSS style for footer cells

Slots:
  • header [ public, TKComponent, multi]: contains all header cells
  • footer [ public, TKComponent, multi]: contains all footer cells
  • rowX [ public, TKComponent, multi]: there is one rowX slot for each row, where X is a number from 0 to one less than the number of rows.


Constructor & Destructor Documentation

TKTable::__construct ( autoFirstRow = true  ) 

Creates new table.

Parameters:
$autoFirstRow [boolean]: if true, the constructor automatically calls addRow() to create an initial first row (this is the default)


Member Function Documentation

TKTable::addData ( data  ) 

Adds a 2d array of data to the table.

Each element in the input array corresponds to a row in the table. If an element in the input array is itself an array, then each of its elements is added to the table as a cell in the current row. Otherwise, the element is added by itself to the current row.

Parameters:
$data [array]: 2d array of data to be loaded into the table.

TKTable::addRow ( id = "",
class = "" 
)

Adds a new row to the table.

All new components are added to this row, unless explicitly specified otherwise. The new row's slot is named rowX where X is the new number of rows minus one.

Parameters:
$id [string]: XML id to assign to row, if desired (default row ID is generated otherwise)
$class [string]: CSS class to set on the row

TKTable::getRowId ( rowIdx  ) 

Retrieves row ID associated with given row.

Parameters:
$rowIdx [int]: index of row to retrieve ID for (starting from 0)
Returns:
[string]: ID for row


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:04:49 2010 for Common by  doxygen 1.5.6