PHP Class WhGridView

This grid is an extended version of TbGridView. Features are: - Display an extended summary of the records shown. The extended summary can be configured to any of the WhOperation type of widgets. - Automatic chart display (using WhHighCharts widget), where user can 'switch' between views.
Author: Antonio Ramirez ([email protected])
Inheritance: extends TbGridView
Datei anzeigen Open project: 2amigos/yiiwheels Class Usage Examples

Public Properties

Property Type Description
$chartOptions array if configured, the extended view will display a highcharts chart.
$componentsAfterAjaxUpdate array has scripts that will be executed after components have updated. It is used internally to render scripts required for components to work correctly. You may use it for your own scripts, just make sure it is of type array.
$componentsReadyScripts array hold scripts that will be executed on document ready. It is used internally to render scripts required for components to work correctly. You may use it for your own scripts, just make sure it is of type array.
$extendedSummary array displays an extended summary version. There are different types of summary types, please, see {@link TbSumOperation}, {@link TbSumOfTypeOperation},{@link TbPercentOfTypeGooglePieOperation} {@link TbPercentOfTypeOperation} and {@link TbPercentOfTypeEasyPieOperation}. The following is an example, please review the different types of TbOperation classes to find out more about its configuration parameters.
 'extendedSummary' => array(
     'title' => '',      // the extended summary title
     'columns' => array( // the 'columns' that will be displayed at the extended summary
         'id' => array(  // column name "id"
             'class' => 'TbSumOperation', // what is the type of TbOperation we are going to display
             'label' => 'Sum of Ids'     // label is name of label of the resulted value (ie Sum of Ids:)
         ),
         'results' => array(   // column name "results"
             'class' => 'TbPercentOfTypeGooglePieOperation', // the type of TbOperation
             'label' => 'How Many Of Each? ', // the label of the operation
             'types' => array(               // TbPercentOfTypeGooglePieOperation "types" attributes
                 '0' => array('label' => 'zeros'),   // a value of "0" will be labelled "zeros"
                 '1' => array('label' => 'ones'),    // a value of "1" will be labelled "ones"
                 '2' => array('label' => 'twos'))    // a value of "2" will be labelled "twos"
         )
     )
),
$extendedSummaryCssClass string is the class name of the layer containing the extended summary
$extendedSummaryOptions array the HTML attributes of the layer containing the extended summary
$fixedHeader boolean if set to true will keep the header fixed position
$headerOffset integer , when $fixedHeader is set to true, headerOffset will position table header top position at $headerOffset. If you are using bootstrap and has navigation top fixed, its height is 40px, so it is recommended to use $headerOffset=40;
$responsiveTable whether to make the grid responsive
$template the template to be used to control the layout of various sections in the view. These tokens are recognized: {extendedSummary}, {summary}, {items} and {pager}. They will be replaced with the extended summary, summary text, the items, and the pager.

Protected Properties

Property Type Description
$displayExtendedSummary boolean a helper property that is set to true if we have to render the extended summary
$extendedSummaryOperations array hold the supported operation types
$extendedSummaryTypes WhOperation[] hold the current configured TbOperation that will process column values.

Public Methods

Method Description
getColumnByName ( string $name ) : CDataColumn | null Helper function to get a column by its name
init ( ) Widget initialization
registerCustomClientScript ( ) Registers required css, js and scripts Note: This script must be run at the end of content rendering not at the beginning as it is common with normal CGridViews
renderContent ( ) Renders grid content
renderExtendedSummary ( ) Renders summary
renderExtendedSummaryContent ( ) Renders summary content. Will be appended to
renderTableFooter ( ) Renders the table footer.
renderTableHeader ( ) Renders grid header
renderTableRow ( integer $row ) Renders a table body row.

Protected Methods

Method Description
getAttribute ( CActiveRecord $data, string $attribute ) : mixed Helper function to get an attribute from the data
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
getSummaryOperationInstance ( string $name, array $config ) : mixed Each type of 'extended' summary
initColumns ( ) Creates column objects and initializes them.
parseColumnValue ( CDataColumn $column, integer $row ) : string Parses the value of a column by an operation

Method Details

getAttribute() protected method

Helper function to get an attribute from the data
protected getAttribute ( CActiveRecord $data, string $attribute ) : mixed
$data CActiveRecord
$attribute string the attribute to get
return mixed the attribute value null if none found

getColumnByName() public method

Helper function to get a column by its name
public getColumnByName ( string $name ) : CDataColumn | null
$name string
return CDataColumn | null

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

getSummaryOperationInstance() protected method

Each type of 'extended' summary
protected getSummaryOperationInstance ( string $name, array $config ) : mixed
$name string the name of the column
$config array the configuration of the column at the extendedSummary
return mixed

init() public method

Widget initialization
public init ( )

initColumns() protected method

Creates column objects and initializes them.
protected initColumns ( )

parseColumnValue() protected method

Parses the value of a column by an operation
protected parseColumnValue ( CDataColumn $column, integer $row ) : string
$column CDataColumn
$row integer the current row number
return string

registerCustomClientScript() public method

Registers required css, js and scripts Note: This script must be run at the end of content rendering not at the beginning as it is common with normal CGridViews

renderContent() public method

Renders grid content
public renderContent ( )

renderExtendedSummary() public method

Renders summary

renderExtendedSummaryContent() public method

Renders summary content. Will be appended to

renderTableFooter() public method

Renders the table footer.
public renderTableFooter ( )

renderTableHeader() public method

Renders grid header
public renderTableHeader ( )

renderTableRow() public method

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

Property Details

$chartOptions public_oe property

if configured, the extended view will display a highcharts chart.
public array $chartOptions
return array

$componentsAfterAjaxUpdate public_oe property

has scripts that will be executed after components have updated. It is used internally to render scripts required for components to work correctly. You may use it for your own scripts, just make sure it is of type array.
public array $componentsAfterAjaxUpdate
return array

$componentsReadyScripts public_oe property

hold scripts that will be executed on document ready. It is used internally to render scripts required for components to work correctly. You may use it for your own scripts, just make sure it is of type array.
public array $componentsReadyScripts
return array

$displayExtendedSummary protected_oe property

a helper property that is set to true if we have to render the extended summary
protected bool $displayExtendedSummary
return boolean

$extendedSummary public_oe property

displays an extended summary version. There are different types of summary types, please, see {@link TbSumOperation}, {@link TbSumOfTypeOperation},{@link TbPercentOfTypeGooglePieOperation} {@link TbPercentOfTypeOperation} and {@link TbPercentOfTypeEasyPieOperation}. The following is an example, please review the different types of TbOperation classes to find out more about its configuration parameters.
 'extendedSummary' => array(
     'title' => '',      // the extended summary title
     'columns' => array( // the 'columns' that will be displayed at the extended summary
         'id' => array(  // column name "id"
             'class' => 'TbSumOperation', // what is the type of TbOperation we are going to display
             'label' => 'Sum of Ids'     // label is name of label of the resulted value (ie Sum of Ids:)
         ),
         'results' => array(   // column name "results"
             'class' => 'TbPercentOfTypeGooglePieOperation', // the type of TbOperation
             'label' => 'How Many Of Each? ', // the label of the operation
             'types' => array(               // TbPercentOfTypeGooglePieOperation "types" attributes
                 '0' => array('label' => 'zeros'),   // a value of "0" will be labelled "zeros"
                 '1' => array('label' => 'ones'),    // a value of "1" will be labelled "ones"
                 '2' => array('label' => 'twos'))    // a value of "2" will be labelled "twos"
         )
     )
),
public array $extendedSummary
return array

$extendedSummaryCssClass public_oe property

is the class name of the layer containing the extended summary
public string $extendedSummaryCssClass
return string

$extendedSummaryOperations protected_oe property

hold the supported operation types
protected array $extendedSummaryOperations
return array

$extendedSummaryOptions public_oe property

the HTML attributes of the layer containing the extended summary
public array $extendedSummaryOptions
return array

$extendedSummaryTypes protected_oe property

hold the current configured TbOperation that will process column values.
protected WhOperation[] $extendedSummaryTypes
return WhOperation[]

$fixedHeader public_oe property

if set to true will keep the header fixed position
public bool $fixedHeader
return boolean

$headerOffset public_oe property

, when $fixedHeader is set to true, headerOffset will position table header top position at $headerOffset. If you are using bootstrap and has navigation top fixed, its height is 40px, so it is recommended to use $headerOffset=40;
public int $headerOffset
return integer

$responsiveTable public_oe property

whether to make the grid responsive
public $responsiveTable

$template public_oe property

the template to be used to control the layout of various sections in the view. These tokens are recognized: {extendedSummary}, {summary}, {items} and {pager}. They will be replaced with the extended summary, summary text, the items, and the pager.
public $template