PHP Class TbJsonGridView

Converts TbGridView into a Json Javascript grid when using AJAX updates calls. This grid makes use of localStorage or a custom in memory plugin to avoid repetitive ajax requests/responses and speed up data visualization.
Inheritance: extends TbGridView
Show file Open project: yinhe/yincart

Public Properties

Property Type Description
$cacheTTL integer how long we keep the responses on cache? It will depend on cacheTTLType (seconds, minutes, hours)
$cacheTTLType the type of cache duration s: seconds m: minutes h: hours
$json boolean true when there is an AJAX request. TbJsonGridView expect a JSON response.
$localCache boolean whether we use client ajax cache or not. True by default.
$pager the configuration for the pager. Defaults to array('class'=>'ext.bootstrap.widgets.TbPager').
$template string Overridden standard template to add second pager on top.

Public Methods

Method Description
init ( ) Initializes $json property to find out whether ajax request or not
registerClientScript ( ) Registers necessary client scripts.
renderItems ( ) Renders the data items for the grid view.
renderPager ( ) Renders the pager.
renderTableBody ( ) Renders the table body.
renderTableRow ( integer $row ) Renders a table body row.
renderTemplate ( string $id, string $text ) : string Encloses the given JavaScript within a script tag.
run ( ) Renders the view.

Protected Methods

Method Description
createDataColumn ( mixed $text ) : TbJSONDataColumn | TbDataColumn | CDataColumn Creates a column based on a shortcut column specification string.
initColumns ( ) Creates column objects and initializes them.
renderTableBodyJSON ( integer $rows ) : array Renders the body table for JSON requests - assumed ajax is for JSON
renderTableRowJSON ( integer $row ) : array Renders a table body row for JSON requests - assumed ajax is for JSON
renderTemplates ( ) Renders the required templates for the client engine (jqote2 used)

Method Details

createDataColumn() protected method

Creates a column based on a shortcut column specification string.
protected createDataColumn ( mixed $text ) : TbJSONDataColumn | TbDataColumn | CDataColumn
$text mixed the column specification string
return TbJSONDataColumn | TbDataColumn | CDataColumn the column instance

init() public method

Initializes $json property to find out whether ajax request or not
public init ( )

initColumns() protected method

Creates column objects and initializes them.
protected initColumns ( )

registerClientScript() public method

Registers necessary client scripts.

renderItems() public method

Renders the data items for the grid view.
public renderItems ( )

renderPager() public method

Renders the pager.
public renderPager ( )

renderTableBody() public method

Renders the table body.
public renderTableBody ( )

renderTableBodyJSON() protected method

Renders the body table for JSON requests - assumed ajax is for JSON
protected renderTableBodyJSON ( integer $rows ) : array
$rows integer
return array

renderTableRow() public method

Renders a table body row.
public renderTableRow ( integer $row )
$row integer the row number (zero-based).

renderTableRowJSON() protected method

Renders a table body row for JSON requests - assumed ajax is for JSON
protected renderTableRowJSON ( integer $row ) : array
$row integer
return array

renderTemplate() public method

Encloses the given JavaScript within a script tag.
public renderTemplate ( string $id, string $text ) : string
$id string
$text string the JavaScript to be enclosed
return string the enclosed JavaScript

renderTemplates() protected method

Renders the required templates for the client engine (jqote2 used)
protected renderTemplates ( )

run() public method

This is the main entry of the whole view rendering. Child classes should mainly override {@link renderContent} method.
public run ( )

Property Details

$cacheTTL public property

how long we keep the responses on cache? It will depend on cacheTTLType (seconds, minutes, hours)
public int $cacheTTL
return integer

$cacheTTLType public property

the type of cache duration s: seconds m: minutes h: hours
public $cacheTTLType

$json public property

true when there is an AJAX request. TbJsonGridView expect a JSON response.
public bool $json
return boolean

$localCache public property

whether we use client ajax cache or not. True by default.
public bool $localCache
return boolean

$pager public property

the configuration for the pager. Defaults to array('class'=>'ext.bootstrap.widgets.TbPager').
public $pager

$template public property

Overridden standard template to add second pager on top.
public string $template
return string