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 |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__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() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | 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 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.