Yii Framework v1.1.10 Class Reference

CGridColumn

Package zii.widgets.grid
Inheritance abstract class CGridColumn » CComponent
Subclasses CButtonColumn, CCheckBoxColumn, CDataColumn, CLinkColumn
Since 1.1
Version $Id: CGridColumn.php 3426 2011-10-25 00:01:09Z alexander.makarow $
Source Code framework/zii/widgets/grid/CGridColumn.php
CGridColumn is the base class for all grid view column classes.

A CGridColumn object represents the specification for rendering the cells in a particular grid view column.

In a column, there is one header cell, multiple data cells, and an optional footer cell. Child classes may override renderHeaderCellContent, renderDataCellContent and renderFooterCellContent to customize how these cells are rendered.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
cssClassExpression string a PHP expression that is evaluated for every data cell and whose result is used as the CSS class name for the data cell. CGridColumn
footerHtmlOptions array the HTML options for the footer cell tag. CGridColumn
grid CGridView the grid view object that owns this column. CGridColumn
hasFooter boolean whether this column has a footer cell. CGridColumn
headerHtmlOptions array the HTML options for the header cell tag. CGridColumn
htmlOptions array the HTML options for the data cell tags. CGridColumn
id string the ID of this column. CGridColumn
visible boolean whether this column is visible. CGridColumn

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. CComponent
__construct() Constructor. CGridColumn
__get() Returns a property value, an event handler list or a behavior based on its name. CComponent
__isset() Checks if a property value is null. CComponent
__set() Sets value of a component property. CComponent
__unset() Sets a component property to be null. CComponent
asa() Returns the named behavior object. CComponent
attachBehavior() Attaches a behavior to this component. CComponent
attachBehaviors() Attaches a list of behaviors to the component. CComponent
attachEventHandler() Attaches an event handler to an event. CComponent
canGetProperty() Determines whether a property can be read. CComponent
canSetProperty() Determines whether a property can be set. CComponent
detachBehavior() Detaches a behavior from the component. CComponent
detachBehaviors() Detaches all behaviors from the component. CComponent
detachEventHandler() Detaches an existing event handler. CComponent
disableBehavior() Disables an attached behavior. CComponent
disableBehaviors() Disables all behaviors attached to this component. CComponent
enableBehavior() Enables an attached behavior. CComponent
enableBehaviors() Enables all behaviors attached to this component. CComponent
evaluateExpression() Evaluates a PHP expression or callback under the context of this component. CComponent
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getHasFooter() Returns whether this column has a footer cell. This is determined based on whether footer is set. CGridColumn
hasEvent() Determines whether an event is defined. CComponent
hasEventHandler() Checks whether the named event has attached handlers. CComponent
hasProperty() Determines whether a property is defined. CComponent
init() Initializes the column. CGridColumn
raiseEvent() Raises an event. CComponent
renderDataCell() Renders a data cell. CGridColumn
renderFilterCell() Renders the filter cell. CGridColumn
renderFooterCell() Renders the footer cell. CGridColumn
renderHeaderCell() Renders the header cell. CGridColumn

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
renderDataCellContent() Renders the data cell content. CGridColumn
renderFilterCellContent() Renders the filter cell content. CGridColumn
renderFooterCellContent() Renders the footer cell content. CGridColumn
renderHeaderCellContent() Renders the header cell content. CGridColumn

Property Details

cssClassExpression property
public string $cssClassExpression;

a PHP expression that is evaluated for every data cell and whose result is used as the CSS class name for the data cell. In this expression, the variable $row the row number (zero-based); $data the data model for the row; and $this the column object.

public string $footer;

the footer cell text. Note that it will not be HTML-encoded.

footerHtmlOptions property
public array $footerHtmlOptions;

the HTML options for the footer cell tag.

grid property
public CGridView $grid;

the grid view object that owns this column.

hasFooter property read-only
public boolean getHasFooter()

whether this column has a footer cell. This is determined based on whether footer is set.

header property
public string $header;

the header cell text. Note that it will not be HTML-encoded.

headerHtmlOptions property
public array $headerHtmlOptions;

the HTML options for the header cell tag.

htmlOptions property
public array $htmlOptions;

the HTML options for the data cell tags.

id property
public string $id;

the ID of this column. This value should be unique among all grid view columns. If this is set, it will be assigned one automatically.

visible property
public boolean $visible;

whether this column is visible. Defaults to true.

Method Details

__construct() method
public void __construct(CGridView $grid)
$grid CGridView the grid view that owns this column.
Source Code: framework/zii/widgets/grid/CGridColumn.php#76 (show)
public function __construct($grid)
{
    
$this->grid=$grid;
}

Constructor.

getHasFooter() method
public boolean getHasFooter()
{return} boolean whether this column has a footer cell. This is determined based on whether footer is set.
Source Code: framework/zii/widgets/grid/CGridColumn.php#94 (show)
public function getHasFooter()
{
    return 
$this->footer!==null;
}

init() method
public void init()
Source Code: framework/zii/widgets/grid/CGridColumn.php#86 (show)
public function init()
{
}

Initializes the column. This method is invoked by the grid view when it initializes itself before rendering. You may override this method to prepare the column for rendering.

renderDataCell() method
public void renderDataCell(integer $row)
$row integer the row number (zero-based)
Source Code: framework/zii/widgets/grid/CGridColumn.php#125 (show)
public function renderDataCell($row)
{
    
$data=$this->grid->dataProvider->data[$row];
    
$options=$this->htmlOptions;
    if(
$this->cssClassExpression!==null)
    {
        
$class=$this->evaluateExpression($this->cssClassExpression,array('row'=>$row,'data'=>$data));
        if(isset(
$options['class']))
            
$options['class'].=' '.$class;
        else
            
$options['class']=$class;
    }
    echo 
CHtml::openTag('td',$options);
    
$this->renderDataCellContent($row,$data);
    echo 
'</td>';
}

Renders a data cell.

renderDataCellContent() method
protected void renderDataCellContent(integer $row, mixed $data)
$row integer the row number (zero-based)
$data mixed the data associated with the row
Source Code: framework/zii/widgets/grid/CGridColumn.php#178 (show)
protected function renderDataCellContent($row,$data)
{
    echo 
$this->grid->blankDisplay;
}

Renders the data cell content. This method SHOULD be overridden to customize the rendering of the data cell.

renderFilterCell() method (available since v1.1.1)
public void renderFilterCell()
Source Code: framework/zii/widgets/grid/CGridColumn.php#103 (show)
public function renderFilterCell()
{
    echo 
"<td>";
    
$this->renderFilterCellContent();
    echo 
"</td>";
}

Renders the filter cell.

renderFilterCellContent() method (available since v1.1.1)
protected void renderFilterCellContent()
Source Code: framework/zii/widgets/grid/CGridColumn.php#189 (show)
protected function renderFilterCellContent()
{
    echo 
$this->grid->blankDisplay;
}

Renders the filter cell content. The default implementation simply renders a space. This method may be overridden to customize the rendering of the filter cell (if any).

renderFooterCell() method
public void renderFooterCell()
Source Code: framework/zii/widgets/grid/CGridColumn.php#145 (show)
public function renderFooterCell()
{
    echo 
CHtml::openTag('td',$this->footerHtmlOptions);
    
$this->renderFooterCellContent();
    echo 
'</td>';
}

Renders the footer cell.

renderFooterCellContent() method
protected void renderFooterCellContent()
Source Code: framework/zii/widgets/grid/CGridColumn.php#167 (show)
protected function renderFooterCellContent()
{
    echo 
trim($this->footer)!=='' $this->footer $this->grid->blankDisplay;
}

Renders the footer cell content. The default implementation simply renders footer. This method may be overridden to customize the rendering of the footer cell.

renderHeaderCell() method
public void renderHeaderCell()
Source Code: framework/zii/widgets/grid/CGridColumn.php#113 (show)
public function renderHeaderCell()
{
    
$this->headerHtmlOptions['id']=$this->id;
    echo 
CHtml::openTag('th',$this->headerHtmlOptions);
    
$this->renderHeaderCellContent();
    echo 
"</th>";
}

Renders the header cell.

renderHeaderCellContent() method
protected void renderHeaderCellContent()
Source Code: framework/zii/widgets/grid/CGridColumn.php#157 (show)
protected function renderHeaderCellContent()
{
    echo 
trim($this->header)!=='' $this->header $this->grid->blankDisplay;
}

Renders the header cell content. The default implementation simply renders header. This method may be overridden to customize the rendering of the header cell.

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.