本文整理匯總了PHP中GridView::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP GridView::init方法的具體用法?PHP GridView::init怎麽用?PHP GridView::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GridView
的用法示例。
在下文中一共展示了GridView::init方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
parent::init();
if ($this->rankKey === null) {
if ($this->dataProvider->getItemCount() > 0) {
$data = $this->dataProvider->data[0];
$keys = array_keys($data instanceof CActiveRecord ? $data->attributes : $data);
$this->rankKey = isset($data['rank']) ? 'rank' : $keys[0];
}
}
$hasRankColumn = false;
foreach ($this->columns as $column) {
if ($column instanceof RankColumn) {
$hasRankColumn = true;
break;
}
}
if ($hasRankColumn === false) {
array_unshift($this->columns, Yii::createComponent(array('class' => 'RankColumn', 'value' => '$displayRank', 'header' => Yii::t('statistics', 'Rank')), $this));
}
$this->lastRank = $this->rank;
if ($this->count != $this->rank && $this->rankKey !== null) {
$this->rank++;
if ($this->dataProvider->getItemCount() > 0) {
$data = $this->dataProvider->data[0];
$this->lastRankValue = CHtml::value($data, $this->rankKey);
}
}
}