PHP Class WhRelationalColumn

Displays a clickable column that will make an ajax request and display its resulting data into a new row.
Author: Antonio Ramirez ([email protected])
Inheritance: extends TbDataColumn
Show file Open project: 2amigos/yiiwheels

Public Properties

Property Type Description
$afterAjaxUpdate a javascript function that will be invoked if an AJAX call occurs. The function signature is function(tr, rowid, data)
  • tr is the newly created TR HTML object that will display the returned server data.
  • rowid the model id of the row.
  • data is the data returned by the server that is already displayed on the row.
Note: This handler is not called for JSONP requests. Example (add in a call to TbRelationalColumn):
 ...
 'afterAjaxUpdate'=>'js:function(tr,rowid, data){ console.log(rowid); }',
 ...
$ajaxErrorMessage string the message that is displayed on the newly created row in case there is an AJAX error.
$cacheData boolean if set to true, there won't be more than one AJAX request. If set to false, the widget will continuously make AJAX requests. This is useful if the data could vary. If the data doesn't change then is better to set it to true. Defaults to true.
$cssClass string the class name that will wrap up the cell content. Important Note: this class will be used as the trigger for the AJAX call, so make sure is unique for the column.
$url string the route to call via AJAX to get the data from

Public Methods

Method Description
init ( ) widget initialization
registerClientScript ( ) Register script that will handle its behavior
renderDataCell ( integer $row ) Overrides CDataColumn renderDataCell in order to wrap up its content with the object that will be used as a trigger.

Protected Methods

Method Description
getPrimaryKey ( CActiveRecord $data ) : null | string Helper function to return the primary key of the $data * IMPORTANT: composite keys on CActiveDataProviders will return the keys joined by comma

Method Details

getPrimaryKey() protected method

Helper function to return the primary key of the $data * IMPORTANT: composite keys on CActiveDataProviders will return the keys joined by comma
protected getPrimaryKey ( CActiveRecord $data ) : null | string
$data CActiveRecord
return null | string

init() public method

widget initialization
public init ( )

registerClientScript() public method

Register script that will handle its behavior

renderDataCell() public method

Important: Making use of links as a content for this of column is an error.
public renderDataCell ( integer $row )
$row integer

Property Details

$afterAjaxUpdate public property

a javascript function that will be invoked if an AJAX call occurs. The function signature is function(tr, rowid, data)
  • tr is the newly created TR HTML object that will display the returned server data.
  • rowid the model id of the row.
  • data is the data returned by the server that is already displayed on the row.
Note: This handler is not called for JSONP requests. Example (add in a call to TbRelationalColumn):
 ...
 'afterAjaxUpdate'=>'js:function(tr,rowid, data){ console.log(rowid); }',
 ...
public $afterAjaxUpdate

$ajaxErrorMessage public property

the message that is displayed on the newly created row in case there is an AJAX error.
public string $ajaxErrorMessage
return string

$cacheData public property

if set to true, there won't be more than one AJAX request. If set to false, the widget will continuously make AJAX requests. This is useful if the data could vary. If the data doesn't change then is better to set it to true. Defaults to true.
public bool $cacheData
return boolean

$cssClass public property

the class name that will wrap up the cell content. Important Note: this class will be used as the trigger for the AJAX call, so make sure is unique for the column.
public string $cssClass
return string

$url public property

the route to call via AJAX to get the data from
public string $url
return string