| 包 | 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 $ |
| 源码 |
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 |
公共方法
| 方法 | 描述 | 定义在 |
|---|---|---|
| __call() | 如果类中没有调的方法名,则调用这个方法。 | CComponent |
| __construct() | 构造方法。 | CGridColumn |
| __get() | 返回一个属性值、一个事件处理程序列表或一个行为名称。 | CComponent |
| __isset() | 检查一个属性是否为null。 | CComponent |
| __set() | 设置一个组件的属性值。 | CComponent |
| __unset() | 设置一个组件的属性为null。 | CComponent |
| asa() | 返回这个名字的行为对象。 | CComponent |
| attachBehavior() | 附加一个行为到组件。 | CComponent |
| attachBehaviors() | 附加一个行为列表到组件。 | CComponent |
| attachEventHandler() | 为事件附加一个事件处理程序。 | CComponent |
| canGetProperty() | 确定属性是否可读。 | CComponent |
| canSetProperty() | 确定属性是否可写。 | CComponent |
| detachBehavior() | 从组件中分离一个行为。 | CComponent |
| detachBehaviors() | 从组件中分离所有行为。 | CComponent |
| detachEventHandler() | 分离一个存在的事件处理程序。 | CComponent |
| disableBehavior() | 禁用一个附加行为。 | CComponent |
| disableBehaviors() | 禁用组件附加的所有行为。 | CComponent |
| enableBehavior() | 启用一个附加行为。 | CComponent |
| enableBehaviors() | 启用组件附加的所有行为。 | CComponent |
| evaLuateExpression() | 计算一个PHP表达式,或根据组件上下文执行回调。 | CComponent |
| getEventHandlers() | 返回一个事件的附加处理程序列表。 | CComponent |
| getHasFooter() | 返回确定此列是否有底部元件。 这决定基于是否footer已设置。 | CGridColumn |
| hasEvent() | 确定一个事件是否定义。 | CComponent |
| hasEventHandler() | 检查事件是否有附加的处理程序。 | CComponent |
| hasProperty() | 确定属性是否被定义。 | CComponent |
| init() | 初始化列。 | CGridColumn |
| raiseEvent() | 发起一个事件。 | CComponent |
| renderDataCell() | 渲染一个数据元件。 | CGridColumn |
| renderFilterCell() | 渲染过滤器元件。 | CGridColumn |
| renderFooterCell() | 渲染底部元件。 | CGridColumn |
| renderHeaderCell() | 渲染头部元件。 | 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 function 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.