本文整理汇总了PHP中yii\grid\DataColumn::renderHeaderCellContent方法的典型用法代码示例。如果您正苦于以下问题:PHP DataColumn::renderHeaderCellContent方法的具体用法?PHP DataColumn::renderHeaderCellContent怎么用?PHP DataColumn::renderHeaderCellContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\grid\DataColumn
的用法示例。
在下文中一共展示了DataColumn::renderHeaderCellContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHeaderCellContent
public function renderHeaderCellContent()
{
if ($this->header !== null || $this->label === null && $this->attribute === null) {
return parent::renderHeaderCellContent();
}
$provider = $this->grid->dataProvider;
if ($this->label === null) {
if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
/* @var $model Model */
$model = new $provider->query->modelClass();
$label = $model->getAttributeLabel($this->attribute);
} else {
$models = $provider->getModels();
if (($model = reset($models)) instanceof Model) {
/* @var $model Model */
$label = $model->getAttributeLabel($this->attribute);
} else {
$label = Inflector::camel2words($this->attribute);
}
}
} else {
$label = $this->label;
}
return $this->encodeLabel ? Html::encode($label) : $label;
}
示例2: renderHeaderCellContent
protected function renderHeaderCellContent()
{
$parentHeader = parent::renderHeaderCellContent();
$sort = $this->grid->dataProvider->getSort();
$direction = $sort->getAttributeOrder($this->attribute);
if ($direction === null) {
return $parentHeader;
}
$class = $direction == SORT_ASC ? 'asc' : 'desc';
return $parentHeader . Html::tag('span', '', ['class' => [$class]]);
}
示例3: renderFooterCellContent
/**
* Used to render footer like header
*/
protected function renderFooterCellContent()
{
return parent::renderHeaderCellContent();
}
示例4: renderHeaderCellContent
/**
* @inheritdoc
*/
protected function renderHeaderCellContent()
{
if ($this->header !== null || $this->label === null && $this->attribute === null) {
return parent::renderHeaderCellContent();
}
$provider = $this->grid->dataProvider;
if ($this->label === null) {
$label =& $this->label;
if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
/* @var $model Model */
$model = new $provider->query->modelClass();
$label = $model->getAttributeLabel($this->attribute);
} else {
$models = $provider->getModels();
if (($model = reset($models)) instanceof Model) {
/* @var $model Model */
$label = $model->getAttributeLabel($this->attribute);
} else {
$label = Inflector::camel2words($this->attribute);
}
}
} else {
$label = $this->label;
}
if ($this->attribute !== null && $this->enableSorting && ($sort = $provider->getSort()) !== false && $sort->hasAttribute($this->attribute)) {
return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => $this->encodeLabel ? Html::encode($label) : $label]));
} else {
return $this->encodeLabel ? Html::encode($label) : $label;
}
}