system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

CGridColumn

zii.widgets.grid
继承 abstract class CGridColumn » CComponent
子类 CButtonColumn, CCheckBoxColumn, CDataColumn, CLinkColumn
可用自 1.1
源码 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.

公共属性

隐藏继承的属性

属性类型描述被定义在
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
filterCellContent string Returns the filter cell content. CGridColumn
filterHtmlOptions array the HTML options for the filter cell tag. CGridColumn
footerCellContent string Returns the footer cell content. 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
headerCellContent string Returns the header cell content. 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

公共方法

隐藏继承的方法

方法描述被定义在
__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
getDataCellContent() Returns the data cell content. CGridColumn
getEventHandlers() Returns the list of attached event handlers for an event. CComponent
getFilterCellContent() Returns the filter cell content. CGridColumn
getFooterCellContent() Returns the footer cell content. CGridColumn
getHasFooter() Returns whether this column has a footer cell. This is determined based on whether footer is set. CGridColumn
getHeaderCellContent() Returns the header cell content. 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

受保护的方法

隐藏继承的方法

方法描述被定义在
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

属性详情

cssClassExpression 属性
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, you can use the following variables:

  • $row the row number (zero-based)
  • $data the data model for the row
  • $this the column object
The PHP expression will be evaluated using evaluateExpression.

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

filterCellContent 属性 只读 (自版本 v1.1.16 可用)
public string getFilterCellContent()

Returns the filter cell content. The default implementation simply returns an empty column. This method may be overridden to customize the rendering of the filter cell (if any).

filterHtmlOptions 属性
public array $filterHtmlOptions;

the HTML options for the filter cell tag.

public string $footer;

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

footerCellContent 属性 只读 (自版本 v1.1.16 可用)
public string getFooterCellContent()

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

footerHtmlOptions 属性
public array $footerHtmlOptions;

the HTML options for the footer cell tag.

grid 属性
public CGridView $grid;

the grid view object that owns this column.

hasFooter 属性 只读
public boolean getHasFooter()

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

header 属性
public string $header;

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

headerCellContent 属性 只读 (自版本 v1.1.16 可用)
public string getHeaderCellContent()

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

headerHtmlOptions 属性
public array $headerHtmlOptions;

the HTML options for the header cell tag.

htmlOptions 属性
public array $htmlOptions;

the HTML options for the data cell tags.

id 属性
public string $id;

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

visible 属性
public boolean $visible;

whether this column is visible. Defaults to true.

方法详情

__construct() 方法
public void __construct(CGridView $grid)
$grid CGridView the grid view that owns this column.
源码: framework/zii/widgets/grid/CGridColumn.php#89 (显示)
public function __construct($grid)
{
    
$this->grid=$grid;
}

Constructor.

getDataCellContent() 方法 (自版本 v1.1.16 可用)
public string getDataCellContent(integer $row)
$row integer the row number (zero-based) The data for this row is available via $this->grid->dataProvider->data[$row];
{return} string the data cell content.
源码: framework/zii/widgets/grid/CGridColumn.php#218 (显示)
public function getDataCellContent($row)
{
    return 
$this->grid->blankDisplay;
}

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

getFilterCellContent() 方法 (自版本 v1.1.16 可用)
public string getFilterCellContent()
{return} string the filter cell content.
源码: framework/zii/widgets/grid/CGridColumn.php#241 (显示)
public function getFilterCellContent()
{
    return 
$this->grid->blankDisplay;
}

Returns the filter cell content. The default implementation simply returns an empty column. This method may be overridden to customize the rendering of the filter cell (if any).

getFooterCellContent() 方法 (自版本 v1.1.16 可用)
public string getFooterCellContent()
{return} string the footer cell content.
源码: framework/zii/widgets/grid/CGridColumn.php#196 (显示)
public function getFooterCellContent()
{
    return 
trim($this->footer)!=='' $this->footer $this->grid->blankDisplay;
}

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

getHasFooter() 方法
public boolean getHasFooter()
{return} boolean whether this column has a footer cell. This is determined based on whether footer is set.
源码: framework/zii/widgets/grid/CGridColumn.php#107 (显示)
public function getHasFooter()
{
    return 
$this->footer!==null;
}

getHeaderCellContent() 方法 (自版本 v1.1.16 可用)
public string getHeaderCellContent()
{return} string the header cell content.
源码: framework/zii/widgets/grid/CGridColumn.php#175 (显示)
public function getHeaderCellContent()
{
    return 
trim($this->header)!=='' $this->header $this->grid->blankDisplay;
}

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

init() 方法
public void init()
源码: framework/zii/widgets/grid/CGridColumn.php#99 (显示)
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() 方法
public void renderDataCell(integer $row)
$row integer the row number (zero-based)
源码: framework/zii/widgets/grid/CGridColumn.php#138 (显示)
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(!empty(
$class))
        {
            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() 方法
protected void renderDataCellContent(integer $row, mixed $data)
$row integer the row number (zero-based)
$data mixed the data associated with the row
源码: framework/zii/widgets/grid/CGridColumn.php#229 (显示)
protected function renderDataCellContent($row,$data)
{
    echo 
$this->getDataCellContent($row);
}

Renders the data cell content.

renderFilterCell() 方法 (自版本 v1.1.1 可用)
public void renderFilterCell()
源码: framework/zii/widgets/grid/CGridColumn.php#116 (显示)
public function renderFilterCell()
{
    echo 
CHtml::openTag('td',$this->filterHtmlOptions);
    
$this->renderFilterCellContent();
    echo 
"</td>";
}

Renders the filter cell.

renderFilterCellContent() 方法 (自版本 v1.1.1 可用)
protected void renderFilterCellContent()
源码: framework/zii/widgets/grid/CGridColumn.php#251 (显示)
protected function renderFilterCellContent()
{
    echo 
$this->getFilterCellContent();
}

Renders the filter cell content.

renderFooterCell() 方法
public void renderFooterCell()
源码: framework/zii/widgets/grid/CGridColumn.php#161 (显示)
public function renderFooterCell()
{
    echo 
CHtml::openTag('td',$this->footerHtmlOptions);
    
$this->renderFooterCellContent();
    echo 
'</td>';
}

Renders the footer cell.

renderFooterCellContent() 方法
protected void renderFooterCellContent()
源码: framework/zii/widgets/grid/CGridColumn.php#205 (显示)
protected function renderFooterCellContent()
{
    echo 
$this->getFooterCellContent();
}

Renders the footer cell content.

renderHeaderCell() 方法
public void renderHeaderCell()
源码: framework/zii/widgets/grid/CGridColumn.php#126 (显示)
public function renderHeaderCell()
{
    
$this->headerHtmlOptions['id']=$this->id;
    echo 
CHtml::openTag('th',$this->headerHtmlOptions);
    
$this->renderHeaderCellContent();
    echo 
"</th>";
}

Renders the header cell.

renderHeaderCellContent() 方法
protected void renderHeaderCellContent()
源码: framework/zii/widgets/grid/CGridColumn.php#184 (显示)
protected function renderHeaderCellContent()
{
    echo 
$this->getHeaderCellContent();
}

Renders the header cell content.