CGridColumn
| 包 | zii.widgets.grid |
|---|---|
| 继承 | abstract class CGridColumn » CComponent |
| 子类 | CButtonColumn, CCheckBoxColumn, CDataColumn, CLinkColumn |
| 源自 | 1.1 |
| 版本 | $Id: CGridColumn.php 3426 2011-10-25 00:01:09Z alexander.makarow $ |
| 源码 | framework/zii/widgets/grid/CGridColumn.php |
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 | 计算PHP表达式中每一个数据元件,
其结果作为这个数据元件的CSS类名。在这个表达式中,
变量$row是行号(零基础); $data是该行的数据模型;
$this是列的对象。 |
CGridColumn |
| footer | string | 底部元件文本。请注意,它不会变成HTML编码。 | CGridColumn |
| footerHtmlOptions | array | HTML中底部元件标签的选项。 | CGridColumn |
| grid | CGridView | 拥有此列的表格视图对象。 | CGridColumn |
| hasFooter | boolean | 确定此列是否有底部元件。 这决定基于是否footer已设置。 | CGridColumn |
| header | string | 头部元件文本。请注意,它不会变成HTML编码。 | CGridColumn |
| headerHtmlOptions | array | HTML中头部元件标签的选项。 | CGridColumn |
| htmlOptions | array | HTML中数据元件标签的选项。 | CGridColumn |
| id | string | the ID of this column. | CGridColumn |
| visible | boolean | 此列是否可见。默认为true。 | 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 |
属性详细
计算PHP表达式中每一个数据元件,
其结果作为这个数据元件的CSS类名。在这个表达式中,
变量$row是行号(零基础); $data是该行的数据模型;
$this是列的对象。
底部元件文本。请注意,它不会变成HTML编码。
HTML中底部元件标签的选项。
拥有此列的表格视图对象。
确定此列是否有底部元件。 这决定基于是否footer已设置。
头部元件文本。请注意,它不会变成HTML编码。
HTML中头部元件标签的选项。
HTML中数据元件标签的选项。
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.
此列是否可见。默认为true。
方法详细
|
public void __construct(CGridView $grid)
| ||
| $grid | CGridView | 拥有此列的表格视图。 |
public function __construct($grid)
{
$this->grid=$grid;
}
构造方法。
|
public boolean getHasFooter()
| ||
| {return} | boolean | 确定此列是否有底部元件。 这决定基于是否footer已设置。 |
public function getHasFooter()
{
return $this->footer!==null;
}
|
public void init()
|
初始化列。 表格视图初始化时自身渲染之前调用此方法。 您可以重写此方法,准备渲染列。
|
public void renderDataCell(integer $row)
| ||
| $row | integer | 行数(零基础) |
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>';
}
渲染一个数据元件。
|
protected void renderDataCellContent(integer $row, mixed $data)
| ||
| $row | integer | the row number (zero-based) |
| $data | mixed | the data associated with the row |
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.
|
public void renderFilterCell()
|
public function renderFilterCell()
{
echo "<td>";
$this->renderFilterCellContent();
echo "</td>";
}
渲染过滤器元件。
|
protected void renderFilterCellContent()
|
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).
|
public void renderFooterCell()
|
public function renderFooterCell()
{
echo CHtml::openTag('td',$this->footerHtmlOptions);
$this->renderFooterCellContent();
echo '</td>';
}
渲染底部元件。
|
protected void renderFooterCellContent()
|
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.
|
public void renderHeaderCell()
|
public function renderHeaderCell()
{
$this->headerHtmlOptions['id']=$this->id;
echo CHtml::openTag('th',$this->headerHtmlOptions);
$this->renderHeaderCellContent();
echo "</th>";
}
渲染头部元件。
|
protected void renderHeaderCellContent()
|
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.