renderHeaderCellContent() protected method

protected renderHeaderCellContent ( )
示例#1
0
 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
0
 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
0
 /**
  * Used to render footer like header
  */
 protected function renderFooterCellContent()
 {
     return parent::renderHeaderCellContent();
 }
示例#4
0
 /**
  * @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;
     }
 }