phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
DataTable Class Reference

DataTable widget for displaying list of objects. More...

+ Inheritance diagram for DataTable:
+ Collaboration diagram for DataTable:

Public Member Functions

 __construct ($identifier, $model, $modelInstance=NULL)
 
 run (JsUtils $js)
 
 refreshTR ()
 
 refreshTD ($fieldName, $jquery, $view)
 
 compile (JsUtils $js=NULL, &$view=NULL)
 
 getFieldValue ($index)
 
 afterCompile ($index, $callback)
 Associates a $callback function after the compilation of the field at $index position The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position. More...
 
 getHtmlComponent ()
 {} More...
 
 getUrls ()
 
 setUrls ($urls)
 Sets the associative array of urls for refreshing, updating or deleting think of defining the update zone with the setTargetSelector method. More...
 
 paginate ($page, $total_rowcount, $items_per_page=10, $pages_visibles=null)
 Paginates the DataTable element with a Semantic HtmlPaginationMenu component. More...
 
 autoPaginate ($page=1, $items_per_page=10, $pages_visibles=4)
 Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component. More...
 
 refresh ($compileParts=[ 'tbody'])
 
 addSearchInToolbar ($position=Direction::RIGHT)
 Adds a search input in toolbar. More...
 
 getSearchField ()
 
 onNewRow ($callback)
 The callback function called after the insertion of each row when fromDatabaseObjects is called callback function takes the parameters $row : the row inserted and $object: the instance of model used. More...
 
 asForm ()
 Returns a form corresponding to the Datatable. More...
 
 setTargetSelector ($_targetSelector)
 Sets the response element selector for Edit and Delete request with ajax. More...
 
 getRefreshSelector ()
 
 setRefreshSelector ($_refreshSelector)
 
 show ($modelInstance)
 {} More...
 
 getRowClass ()
 
 setRowClass ($_rowClass)
 Sets the default row class (tr class) More...
 
 setEmptyMessage ($_emptyMessage)
 Sets the message displayed when there is no record. More...
 
 setSortable ($colIndex=NULL)
 
 setActiveRowSelector ($class="active", $event="click", $multiple=false)
 
 getActiveRowClass ()
 
 hasActiveRowSelector ()
 
 hideColumn ($colIndex)
 
 setColWidth ($colIndex, $width)
 
 setColWidths ($_colWidths)
 
 setColAlignment ($colIndex, $alignment)
 
 trigger ($event, $params="[]")
 
 onActiveRowChange ($jsCode)
 
 getDeleteBehavior ()
 
 getEditBehavior ()
 
 getDisplayBehavior ()
 
 setDisplayBehavior ($_displayBehavior)
 
 getGroupByFields ()
 
 setGroupByFields ($_groupByFields)
 
 addGroupBy ($index)
 
 setVisibleHover ($_visibleHover)
 
 getPaginationToolbar ()
 
 setInverted ($recursive=true)
 
 setFocusable (bool $focusable)
 
 setFormCaption ($caption)
 
 getNamePrefix ()
 
 setNamePrefix ($namePrefix)
 
- Public Member Functions inherited from Widget
 __construct ($identifier, $model, $modelInstance=NULL)
 
 show ($modelInstance)
 
 getModel ()
 
 setModel ($_model)
 
 getInstanceViewer ()
 
 setInstanceViewer ($_instanceViewer)
 
 getHtmlComponent ()
 
 setAttached ($value=true)
 
 afterCompile ($index, $callback)
 Associates a $callback function after the compilation of the field at $index position The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position. More...
 
 setColor ($color)
 
 setCaptions ($captions)
 
 setCaption ($index, $caption)
 
 setFields ($fields)
 
 addField ($field, $key=null)
 
 addFields ($fields)
 
 countFields ()
 
 addMessage ($attributes=NULL, $fieldName="message")
 
 addErrorMessage ()
 
 insertField ($index, $field, $key=null)
 
 insertInField ($index, $field, $key=null)
 
 setValueFunction ($index, $callback)
 Defines the function which displays the field value. More...
 
 setIdentifierFunction ($callback)
 
 getToolbar ()
 
 addInToolbar ($element, $callback=NULL)
 Adds a new element in toolbar. More...
 
 addItemInToolbar ($caption, $icon=NULL, $callback=NULL)
 
 addItemsInToolbar (array $items, $callback=NULL)
 
 addDropdownInToolbar ($value, $items, $callback=NULL)
 
 addButtonInToolbar ($caption, $cssStyle=null, $callback=NULL)
 
 addButtonsInToolbar (array $captions, $asIcon=false, $callback=NULL)
 
 addLabelledIconButtonInToolbar ($caption, $icon, $before=true, $labeled=false)
 
 addSubmitInToolbar ($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL)
 
 setCaptionCallback ($captionCallback)
 Defines a callback function to call for modifying captions function parameters 0are. More...
 
 setEdition ($_edition=true)
 Makes the input fields editable. More...
 
 setDefaultValueFunction ($defaultValueFunction)
 Defines the default function which displays fields value. More...
 
 getDefaultValueFunction ()
 
 jsDisabled ($disable=true)
 
 addEditButtonInToolbar ($caption, $callback=NULL)
 
 setToolbar (HtmlMenu $_toolbar)
 
 setToolbarPosition ($_toolbarPosition)
 
 getForm ()
 
 run (JsUtils $js)
 
 setValidationParams (array $_validationParams)
 Sets the parameters for the Form validation (on, inline, delay...) More...
 
 moveFieldTo ($from, $to)
 
 swapFields ($index1, $index2)
 
 removeField ($index)
 
 asModal ($header=null)
 
 addToProperty ($name, $value, $separator=" ")
 
 getModelInstance ()
 
 hasRules ()
 
- Public Member Functions inherited from HtmlDoubleElement
 __construct ($identifier, $tagName="p")
 
 setContent ($content)
 
 getContent ()
 
 addContent ($content, $before=false)
 
 run (JsUtils $js)
 
 setValue ($value)
 
 wrapContent ($before, $after="")
 
 wrapWith (HtmlDoubleElement $container)
 Wraps the element with a container. More...
 
 getContentInstances ($class)
 
 asLink ($href=NULL, $target=NULL)
 Transforms the element into a link. More...
 
 getTextContent ()
 
 asEditable (HtmlFormField $field, $asForm=false, $setValueProperty="val()")
 
- Public Member Functions inherited from HtmlSingleElement
 __construct ($identifier, $tagName="br")
 
 setClass ($classNames)
 
 addClass ($classNames)
 
 setRole ($value)
 
 setTitle ($value)
 
 setStyle ($value)
 
 run (JsUtils $js)
 
 fromArray ($array)
 
 setSize ($size)
 
- Public Member Functions inherited from BaseHtml
 run (JsUtils $js)
 
 getTagName ()
 
 setTagName ($tagName)
 
 fromArray ($array)
 
 fromDatabaseObjects ($objects, $function)
 
 fromDatabaseObject ($object, $function)
 
 wrap ($before, $after="")
 
 getElementById ($identifier, $elements)
 
 getBsComponent ()
 
 setBsComponent ($bsComponent)
 
 compile (JsUtils $js=NULL, &$view=NULL)
 
 setDraggable ($attr="id", $dropZone=null, $parameters=[])
 Sets the element draggable, and eventualy defines the dropzone (HTML5 drag and drop) More...
 
 asDropZone ($jsCallback="", $jqueryDone="append", $parameters=[])
 Declares the element as a drop zone (HTML5 drag and drop) More...
 
 asFileDropZone ($responseElement=null, $url=null, $progress=null, $jsCallback="", $parameters=[])
 Declares the element as a drop zone for file uploading (HTML5 drag and drop) More...
 
 __toString ()
 
 onPostCompile ($callback)
 
 onPreCompile ($callback)
 
- Public Member Functions inherited from BaseWidget
 __construct ($identifier)
 
 getIdentifier ()
 
 setIdentifier ($identifier)
 
 getLibraryId ()
 
 setLibraryId ($_libraryId)
 

Protected Member Functions

 _generateBehavior ($op, $params, JsUtils $js)
 
 getTable ()
 {} More...
 
 compileExtraElements ($table, $captions)
 
 _applyStyleAttributes ($table)
 
 _hideColumns ()
 
 _generateHeader (HtmlTable $table, $captions)
 
 _generateContent ($table)
 
 _generateGroupByRow ($index, $gbField, $table, $fields, &$activeValues, &$uuids)
 
 _generateRow ($instance, $fields, &$table, $checkedClass=null, $uuids=null)
 
 _generatePagination ($table)
 
 _associatePaginationBehavior (JsUtils $js=NULL, $offset=null)
 
 _compileSearchFieldBehavior (JsUtils $js=NULL)
 
 _associateSearchFieldBehavior (JsUtils $js=NULL, $offset=null)
 
 _getFieldName ($index)
 
 _getFieldCaption ($index)
 
 applyToolbarPosition (string $position, $table, $captions=NULL)
 
 _setToolbarPosition ($table, $captions=NULL)
 
 getTargetSelector ($op)
 
- Protected Member Functions inherited from Widget
 _init ($instanceViewer, $contentKey, $content, $edition)
 
 _getIndex ($fieldName)
 
 _getFieldIdentifier ($prefix, $name="")
 
 _getFieldName ($index)
 
 _getFieldCaption ($index)
 
 _setToolbarPosition ($table, $captions=NULL)
 
 runForm (JsUtils $js)
 
 _compileForm ()
 
- Protected Member Functions inherited from HtmlDoubleElement
 _getContentInstances ($class, $content)
 
 compile_once (\Ajax\JsUtils $js=NULL, &$view=NULL)
 {} More...
 
- Protected Member Functions inherited from BaseHtml
 getTemplate (JsUtils $js=NULL, $view=null)
 
 ctrl ($name, $value, $typeCtrl)
 
 setMemberCtrl (&$name, $value, $typeCtrl)
 
 addToMemberUnique (&$name, $value, $typeCtrl, $separator=" ")
 
 addToMemberCtrl (&$name, $value, $typeCtrl, $separator=" ")
 
 addToMember (&$name, $value, $separator=' ')
 
 removeOldValues (&$oldValue, $allValues)
 
 _getElementBy ($callback, $elements)
 
 setWrapBefore ($wrapBefore)
 
 setWrapAfter ($wrapAfter)
 
 compile_once (JsUtils $js=NULL, &$view=NULL)
 
- Protected Member Functions inherited from BaseWidget
 cleanIdentifier ($id)
 

Protected Attributes

 $_searchField
 
 $_urls
 
 $_pagination
 
 $_compileParts
 
 $_deleteBehavior
 
 $_editBehavior
 
 $_displayBehavior
 
 $_visibleHover = false
 
 $_targetSelector
 
 $_refreshSelector
 
 $_emptyMessage
 
 $_json
 
 $_rowClass = "_element"
 
 $_sortable
 
 $_hiddenColumns
 
 $_colWidths
 
 $_paginationToolbar
 
 $_caption
 
 $_namePrefix
 
- Protected Attributes inherited from Widget
 $_model
 
 $_modelInstance
 
 $_instanceViewer
 
 $_toolbar
 
 $_toolbarPosition
 
 $_edition
 
 $_form
 
 $_generated
 
 $_runned
 
 $_hasRules
 
- Protected Attributes inherited from HtmlDoubleElement
 $content
 
 $wrapContentBefore = ""
 
 $wrapContentAfter = ""
 
 $_editableContent
 
- Protected Attributes inherited from BaseHtml
 $_template
 
 $tagName
 
 $_wrapBefore = array()
 
 $_wrapAfter = array()
 
 $_bsComponent
 
 $_compiled = false
 
 $_runned = false
 
 $_postCompile
 
 $_preCompile
 
- Protected Attributes inherited from BaseWidget
 $identifier
 
 $_identifier
 
 $_libraryId
 
 $_self
 

Private Member Functions

 getElementContent ($elm)
 
 addToolbarRow ($part, $table, $captions)
 

Detailed Description

DataTable widget for displaying list of objects.

Version
1.1.3
Author
jc
Since
2.2

Definition at line 27 of file DataTable.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $identifier,
  $model,
  $modelInstance = NULL 
)

Definition at line 68 of file DataTable.php.

Member Function Documentation

◆ _applyStyleAttributes()

_applyStyleAttributes (   $table)
protected

Definition at line 191 of file DataTable.php.

◆ _associatePaginationBehavior()

_associatePaginationBehavior ( JsUtils  $js = NULL,
  $offset = null 
)
protected

Definition at line 333 of file DataTable.php.

◆ _associateSearchFieldBehavior()

_associateSearchFieldBehavior ( JsUtils  $js = NULL,
  $offset = null 
)
protected

Definition at line 363 of file DataTable.php.

◆ _compileSearchFieldBehavior()

_compileSearchFieldBehavior ( JsUtils  $js = NULL)
protected

Definition at line 352 of file DataTable.php.

◆ _generateBehavior()

_generateBehavior (   $op,
  $params,
JsUtils  $js 
)
protected

Definition at line 108 of file DataTable.php.

◆ _generateContent()

_generateContent (   $table)
protected

Definition at line 219 of file DataTable.php.

◆ _generateGroupByRow()

_generateGroupByRow (   $index,
  $gbField,
  $table,
  $fields,
$activeValues,
$uuids 
)
protected

Definition at line 252 of file DataTable.php.

◆ _generateHeader()

_generateHeader ( HtmlTable  $table,
  $captions 
)
protected

Definition at line 208 of file DataTable.php.

◆ _generatePagination()

_generatePagination (   $table)
protected

Definition at line 322 of file DataTable.php.

◆ _generateRow()

_generateRow (   $instance,
  $fields,
$table,
  $checkedClass = null,
  $uuids = null 
)
protected

Definition at line 288 of file DataTable.php.

◆ _getFieldCaption()

_getFieldCaption (   $index)
protected

Definition at line 375 of file DataTable.php.

◆ _getFieldName()

_getFieldName (   $index)
protected

Definition at line 365 of file DataTable.php.

◆ _hideColumns()

_hideColumns ( )
protected

Definition at line 201 of file DataTable.php.

◆ _setToolbarPosition()

_setToolbarPosition (   $table,
  $captions = NULL 
)
protected

Definition at line 395 of file DataTable.php.

◆ addGroupBy()

addGroupBy (   $index)

Definition at line 735 of file DataTable.php.

◆ addSearchInToolbar()

addSearchInToolbar (   $position = Direction::RIGHT)

Adds a search input in toolbar.

Parameters
string$position
Returns

Definition at line 524 of file DataTable.php.

◆ addToolbarRow()

addToolbarRow (   $part,
  $table,
  $captions 
)
private

Definition at line 420 of file DataTable.php.

◆ afterCompile()

afterCompile (   $index,
  $callback 
)

Associates a $callback function after the compilation of the field at $index position The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position.

Parameters
int$indexpostion of the compiled field
callable$callbackfunction called after the field compilation
Returns
DataTable

Definition at line 415 of file DataTable.php.

◆ applyToolbarPosition()

applyToolbarPosition ( string  $position,
  $table,
  $captions = NULL 
)
protected

Definition at line 379 of file DataTable.php.

◆ asForm()

asForm ( )

Returns a form corresponding to the Datatable.

Returns

Definition at line 554 of file DataTable.php.

◆ autoPaginate()

autoPaginate (   $page = 1,
  $items_per_page = 10,
  $pages_visibles = 4 
)

Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component.

Parameters
number$pagethe active page number
number$items_per_pageThe number of items per page
number$pages_visiblesThe number of visible pages in the Pagination component
Returns
DataTable

Definition at line 501 of file DataTable.php.

◆ compile()

compile ( JsUtils  $js = NULL,
$view = NULL 
)

Definition at line 139 of file DataTable.php.

◆ compileExtraElements()

compileExtraElements (   $table,
  $captions 
)
protected

Definition at line 176 of file DataTable.php.

◆ getActiveRowClass()

getActiveRowClass ( )

Definition at line 648 of file DataTable.php.

◆ getDeleteBehavior()

getDeleteBehavior ( )
Returns
mixed

Definition at line 691 of file DataTable.php.

◆ getDisplayBehavior()

getDisplayBehavior ( )
Returns
mixed

Definition at line 707 of file DataTable.php.

◆ getEditBehavior()

getEditBehavior ( )
Returns
mixed

Definition at line 699 of file DataTable.php.

◆ getElementContent()

getElementContent (   $elm)
private

Definition at line 270 of file DataTable.php.

◆ getFieldValue()

getFieldValue (   $index)

Definition at line 277 of file DataTable.php.

◆ getGroupByFields()

getGroupByFields ( )
Returns
mixed

Definition at line 723 of file DataTable.php.

◆ getHtmlComponent()

getHtmlComponent ( )

{}

See also
Widget::getHtmlComponent()
Returns
HtmlTable

Definition at line 439 of file DataTable.php.

◆ getNamePrefix()

getNamePrefix ( )
Returns
mixed

Definition at line 777 of file DataTable.php.

◆ getPaginationToolbar()

getPaginationToolbar ( )
Returns

Definition at line 754 of file DataTable.php.

◆ getRefreshSelector()

getRefreshSelector ( )

Definition at line 583 of file DataTable.php.

◆ getRowClass()

getRowClass ( )

Definition at line 612 of file DataTable.php.

◆ getSearchField()

getSearchField ( )

Definition at line 529 of file DataTable.php.

◆ getTable()

getTable ( )
protected

{}

See also
TableTrait::getTable()

Definition at line 122 of file DataTable.php.

◆ getTargetSelector()

getTargetSelector (   $op)
protected

Definition at line 558 of file DataTable.php.

◆ getUrls()

getUrls ( )

Definition at line 443 of file DataTable.php.

◆ hasActiveRowSelector()

hasActiveRowSelector ( )

Definition at line 652 of file DataTable.php.

◆ hideColumn()

hideColumn (   $colIndex)

Definition at line 656 of file DataTable.php.

◆ onActiveRowChange()

onActiveRowChange (   $jsCode)

Definition at line 682 of file DataTable.php.

◆ onNewRow()

onNewRow (   $callback)

The callback function called after the insertion of each row when fromDatabaseObjects is called callback function takes the parameters $row : the row inserted and $object: the instance of model used.

Parameters
callable$callback
Returns
DataTable

Definition at line 544 of file DataTable.php.

◆ paginate()

paginate (   $page,
  $total_rowcount,
  $items_per_page = 10,
  $pages_visibles = null 
)

Paginates the DataTable element with a Semantic HtmlPaginationMenu component.

Parameters
number$pagethe active page number
number$total_rowcountthe total number of items
number$items_per_pageThe number of items per page
number$pages_visiblesThe number of visible pages in the Pagination component
Returns
DataTable

Definition at line 485 of file DataTable.php.

◆ refresh()

refresh (   $compileParts = [ 'tbody' ])
Parameters
array$compileParts
Returns
DataTable

Definition at line 511 of file DataTable.php.

◆ refreshTD()

refreshTD (   $fieldName,
  $jquery,
  $view 
)

Definition at line 131 of file DataTable.php.

◆ refreshTR()

refreshTR ( )

Definition at line 126 of file DataTable.php.

◆ run()

run ( JsUtils  $js)

Definition at line 76 of file DataTable.php.

◆ setActiveRowSelector()

setActiveRowSelector (   $class = "active",
  $event = "click",
  $multiple = false 
)

Definition at line 643 of file DataTable.php.

◆ setColAlignment()

setColAlignment (   $colIndex,
  $alignment 
)

Definition at line 673 of file DataTable.php.

◆ setColWidth()

setColWidth (   $colIndex,
  $width 
)

Definition at line 663 of file DataTable.php.

◆ setColWidths()

setColWidths (   $_colWidths)

Definition at line 668 of file DataTable.php.

◆ setDisplayBehavior()

setDisplayBehavior (   $_displayBehavior)
Parameters
mixed$_displayBehavior

Definition at line 715 of file DataTable.php.

◆ setEmptyMessage()

setEmptyMessage (   $_emptyMessage)

Sets the message displayed when there is no record.

Parameters
mixed$_emptyMessage
Returns
DataTable

Definition at line 633 of file DataTable.php.

◆ setFocusable()

setFocusable ( bool  $focusable)

Definition at line 765 of file DataTable.php.

◆ setFormCaption()

setFormCaption (   $caption)

Definition at line 769 of file DataTable.php.

◆ setGroupByFields()

setGroupByFields (   $_groupByFields)
Parameters
mixed$_groupByFields

Definition at line 731 of file DataTable.php.

◆ setInverted()

setInverted (   $recursive = true)

Definition at line 758 of file DataTable.php.

◆ setNamePrefix()

setNamePrefix (   $namePrefix)
Parameters
mixed$namePrefix

Definition at line 785 of file DataTable.php.

◆ setRefreshSelector()

setRefreshSelector (   $_refreshSelector)
Parameters
string$_refreshSelector
Returns
DataTable

Definition at line 594 of file DataTable.php.

◆ setRowClass()

setRowClass (   $_rowClass)

Sets the default row class (tr class)

Parameters
string$_rowClass
Returns
DataTable

Definition at line 622 of file DataTable.php.

◆ setSortable()

setSortable (   $colIndex = NULL)

Definition at line 638 of file DataTable.php.

◆ setTargetSelector()

setTargetSelector (   $_targetSelector)

Sets the response element selector for Edit and Delete request with ajax.

Parameters
string | array$_targetSelectorstring or associative array ["edit"=>"edit_selector","delete"=>"delete_selector"]
Returns
DataTable

Definition at line 572 of file DataTable.php.

◆ setUrls()

setUrls (   $urls)

Sets the associative array of urls for refreshing, updating or deleting think of defining the update zone with the setTargetSelector method.

Parameters
string | array$urlsassociative array with keys refresh: for refreshing with search field or pagination, edit : for updating a row, delete: for deleting a row
Returns
DataTable

Definition at line 455 of file DataTable.php.

◆ setVisibleHover()

setVisibleHover (   $_visibleHover)
Parameters
boolean$_visibleHover

Definition at line 746 of file DataTable.php.

◆ show()

show (   $modelInstance)

{}

See also
show()

Definition at line 604 of file DataTable.php.

◆ trigger()

trigger (   $event,
  $params = "[]" 
)

Definition at line 678 of file DataTable.php.

Field Documentation

◆ $_caption

$_caption
protected

Definition at line 64 of file DataTable.php.

◆ $_colWidths

$_colWidths
protected

Definition at line 60 of file DataTable.php.

◆ $_compileParts

$_compileParts
protected

Definition at line 36 of file DataTable.php.

◆ $_deleteBehavior

$_deleteBehavior
protected

Definition at line 38 of file DataTable.php.

◆ $_displayBehavior

$_displayBehavior
protected

Definition at line 42 of file DataTable.php.

◆ $_editBehavior

$_editBehavior
protected

Definition at line 40 of file DataTable.php.

◆ $_emptyMessage

$_emptyMessage
protected

Definition at line 50 of file DataTable.php.

◆ $_hiddenColumns

$_hiddenColumns
protected

Definition at line 58 of file DataTable.php.

◆ $_json

$_json
protected

Definition at line 52 of file DataTable.php.

◆ $_namePrefix

$_namePrefix
protected

Definition at line 66 of file DataTable.php.

◆ $_pagination

$_pagination
protected

Definition at line 34 of file DataTable.php.

◆ $_paginationToolbar

$_paginationToolbar
protected

Definition at line 62 of file DataTable.php.

◆ $_refreshSelector

$_refreshSelector
protected

Definition at line 48 of file DataTable.php.

◆ $_rowClass

$_rowClass = "_element"
protected

Definition at line 54 of file DataTable.php.

◆ $_searchField

$_searchField
protected

Definition at line 30 of file DataTable.php.

◆ $_sortable

$_sortable
protected

Definition at line 56 of file DataTable.php.

◆ $_targetSelector

$_targetSelector
protected

Definition at line 46 of file DataTable.php.

◆ $_urls

$_urls
protected

Definition at line 32 of file DataTable.php.

◆ $_visibleHover

$_visibleHover = false
protected

Definition at line 44 of file DataTable.php.


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