Class HtmlTable
- HtmlElement
- HtmlTableBasic
- HtmlTable
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Creates an Admidio specific table with special methods
This class inherits the common HtmlTableBasic class and extends their elements with custom Admidio table methods. The class should be used to create the html part of all Admidio tables. It has simple methods to add complete rows with their column values to the table. It's also possible to add the jQuery plugin Datatables to each table. Therefore you only need to set a flag when creating the object.
Class: HtmlTable
Code:
// create a simple table with one input field and a button $table = new HtmlTable('simple-table'); $table->addRowHeadingByArray(array('Firstname', 'Lastname', 'Address', 'Phone', 'E-Mail')); $table->addRowByArray(array('Hans', 'Mustermann', 'Sonnenallee 22', '+49 342 59433', 'h.mustermann@example.org')); $table->addRowByArray(array('Anne', 'Musterfrau', 'Seestraße 6', '+34 7433 7433', 'a.musterfrau@example.org')); $table->show(); @endcode
Code:
// create a table with jQuery datatables and align columns to center or right $table = new HtmlTable('simple-table', null, true, true); $table->setColumnAlignByArray(array('left', 'left', 'center', 'right')); $table->addRowHeadingByArray(array('Firstname', 'Lastname', 'Birthday', 'Membership fee')); $table->addRowByArray(array('Hans', 'Mustermann', 'Sonnenallee 22', '14.07.1995', '38,50')); $table->show(); @endcode
Par: Examples
Located at htmltable.php
Methods summary
public
|
#
__construct( string $id,
Constructor creates the table element |
private
|
#
addRowTypeByArray( string $type, array $arrColumnValues, string $id = null, array $arrAttributes = null, integer $colspan = 1, integer $colspanOffset = 1 )
Adds a complete row with all columns to the table. Each column element will be a value of the array parameter. |
public
|
#
addRowHeadingByArray( array $arrColumnValues, string $id = null, array $arrAttributes = null, integer $colspan = 1, integer $colspanOffset = 1 )
Adds a complete row with all columns to the table. This will be the column heading row. Each value of the array represents the heading text for each column. |
public
|
#
addRowByArray( array $arrColumnValues, string $id = null, array $arrAttributes = null, integer $colspan = 1, integer $colspanOffset = 1 )
Adds a complete row with all columns to the table. Each column element will be a value of the array parameter. |
public
|
#
disableDatatablesColumnsSort( integer|int[] $columnsSort )
Disable the sort function for some columns. This is useful if a sorting of the column doesn't make sense because it only show function icons or something equal. |
public
integer
|
#
getDatatablesGroupColumn( )
Return the number of the column which should be grouped when using the jQuery plugin DataTables. |
private
|
#
prepareAndAddColumn( string $type, integer $key, string|string[] $value, integer $colspan = 1, integer $colspanOffset = 1 )
Adds a column to the table. |
public
|
#
setColumnAlignByArray( array $columnsAlign )
Set the align for each column of the current table. This method must be called before a row is added to the table. Each entry of the array represents a column. |
public
|
#
setDatatablesAlternativOrderColumns( integer $selectedColumn, integer|int[] $arrayOrderColumns )
This method will set for a selected column other columns that should be used to order the datatables. For example if you will click the name column than you could set the columns lastname and firstname as alternative order columns and the table will be ordered by lastname and firstname. |
public
|
#
setDatatablesColumnsHide( integer|int[] $columnsHide )
Hide some columns for the user. This is useful if you want to use the column for ordering but won't show the content if this column. |
public
|
#
setDatatablesGroupColumn( integer $columnNumber )
Specify a column that should be used to group data. Everytime the value of this column changed then a new subheader row will be created with the name of the new value. |
public
|
#
setDatatablesOrderColumns( array $arrayOrderColumns )
Set the order of the columns which should be used to sort the rows. |
public
|
#
setDatatablesRowsPerPage( integer $numberRows )
Set the number of rows that should be displayed on one page if the jQuery plugin DataTables is used. |
public
|
#
setMessageIfNoRowsFound( string $messageId, string $messageType = 'default' )
Set a text id of the translation files that should be shown if table has no rows. |
public
|
#
setServerSideProcessing( string $file )
With server-side processing enabled, all paging, searching, ordering actions that DataTables performs are handed off to a server where an SQL engine (or similar) can perform these actions on the large data set. As such, each draw of the table will result in a new Ajax request being made to get the required data. |
public
string
|
Methods inherited from HtmlTableBasic
addColumn()
,
addRow()
,
addTableBody()
,
addTableFooter()
,
addTableHeader()
,
getHtmlTable()
,
setColumnWidth()
,
setColumnsWidth()
,
setRowClasses()
Methods inherited from HtmlElement
addAttribute()
,
addData()
,
addElement()
,
addHtml()
,
addParentElement()
,
closeParentElement()
,
getHtmlElement()
,
setAttributesFromArray()
Properties summary
protected
|
$id
|
|
protected
|
$rowsPerPage
|
|
protected
|
$columnsAlign
|
|
protected
|
$columnsOrder
|
|
protected
|
$groupedColumn
|
|
protected
|
$datatables
|
|
protected
|
$datatablesInitParameters
|
|
protected
|
$datatablesColumnDefs
|
|
protected
|
$messageNoRowsFound
|
|
protected
|
$htmlPage
|
|
protected
|
$serverSideProcessing
|
|
protected
|
$serverSideFile
|
Properties inherited from HtmlTableBasic
$border
,
$columnCount
,
$columnsWidth
,
$rowClasses
,
$rowCount
,
$tbody
,
$tfoot
,
$thead
Properties inherited from HtmlElement
$arrParentElements
,
$currentElement
,
$currentElementAttributes
,
$currentElementDataWritten
,
$htmlString
,
$mainElement
,
$mainElementAttributes
,
$mainElementWritten
,
$nesting
,
$parentFlag