0 フォロワー

クラス yii\grid\DataColumn

継承yii\grid\DataColumn » yii\grid\Column » yii\base\BaseObject
実装yii\base\Configurable
利用可能バージョン2.0
ソースコード https://github.com/yiisoft/yii2/blob/master/framework/grid/DataColumn.php

DataColumn は、yii\grid\GridView ウィジェットのデフォルトの列タイプです。

データ列を表示するために使用され、ソートフィルタリングが可能です。

単純なデータ列定義は、GridViewのデータプロバイダーのデータモデル内の属性を参照します。属性名は$attributeで指定します。

$value$labelを設定することで、ヘッダーとセルの内容をカスタマイズできます。

データ列は、データセルの値データセルの内容を区別します。セルの値は、計算に使用できるフォーマットされていない値であるのに対し、実際のセルの内容は、フォーマットされた値のバージョンであり、HTMLマークアップを含む場合があります。

DataColumnの詳細と使用方法については、データウィジェットに関するガイド記事を参照してください。

公開プロパティ

継承されたプロパティを非表示

プロパティ 説明 定義元
$attribute string この列に関連付けられた属性名。 yii\grid\DataColumn
$content callable 各セルのコンテンツを生成するために使用されるcallableです。 yii\grid\Column
$contentOptions array|Closure データセルタグのHTML属性。 yii\grid\Column
$enableSorting boolean この列によるソートを許可するかどうか。 yii\grid\DataColumn
$encodeLabel boolean ヘッダーラベルをHTMLエンコードするかどうか。 yii\grid\DataColumn
$filter string|array|null|false このデータ列に使用されるフィルタ入力(例:テキストフィールド、ドロップダウンリスト)を表すHTMLコード。 yii\grid\DataColumn
$filterAttribute string|null この列に関連付けられたyii\grid\GridView::$filterModelの属性名。 yii\grid\DataColumn
$filterInputOptions array フィルタ入力フィールドのHTML属性。 yii\grid\DataColumn
$filterOptions array フィルタセルタグのHTML属性。 yii\grid\Column
$footer string フッターセルのコンテンツ。 yii\grid\Column
$footerOptions array フッターセルタグのHTML属性。 yii\grid\Column
$format string|array|Closure 各データモデルの値をどのように表示するか(例:"raw"、"text"、"html"、['date', 'php:Y-m-d'])。 yii\grid\DataColumn
$grid yii\grid\GridView この列を所有するグリッドビューオブジェクト。 yii\grid\Column
$header string|null ヘッダーセルのコンテンツ。 yii\grid\Column
$headerOptions array ヘッダーセルタグのHTML属性。 yii\grid\Column
$label string|null ヘッダーセルに表示されるラベルであり、この列のソートが有効になっている場合、ソートリンクラベルとしても使用されます。 yii\grid\DataColumn
$options array 列グループタグのHTML属性。 yii\grid\Column
$sortLinkOptions array この列のソートが有効になっている場合、yii\data\Sort::link()によって生成されるヘッダーセルのリンクタグのHTML属性。 yii\grid\DataColumn
$value string|Closure|null 現在の列に表示する値を決定するために使用される無名関数または文字列。 yii\grid\DataColumn
$visible boolean この列が表示されるかどうか。 yii\grid\Column

公開メソッド

継承されたメソッドを非表示

メソッド 説明 定義元
__call() クラスメソッドではない名前付きメソッドを呼び出します。 yii\base\BaseObject
__construct() コンストラクタ。 yii\base\BaseObject
__get() オブジェクトプロパティの値を返します。 yii\base\BaseObject
__isset() プロパティが設定されているかどうか(定義されていてnullでない)を確認します。 yii\base\BaseObject
__set() オブジェクトプロパティの値を設定します。 yii\base\BaseObject
__unset() オブジェクトプロパティをnullに設定します。 yii\base\BaseObject
canGetProperty() プロパティを読み取ることができるかどうかを示す値を返します。 yii\base\BaseObject
canSetProperty() プロパティを設定できるかどうかを示す値を返します。 yii\base\BaseObject
className() このクラスの完全修飾名を返します。 yii\base\BaseObject
getDataCellValue() データセルの値を返します。 yii\grid\DataColumn
hasMethod() メソッドが定義されているかどうかを示す値を返します。 yii\base\BaseObject
hasProperty() プロパティが定義されているかどうかを示す値を返します。 yii\base\BaseObject
init() オブジェクトを初期化します。 yii\grid\DataColumn
renderDataCell() データセルをレンダリングします。 yii\grid\Column
renderFilterCell() フィルタセルをレンダリングします。 yii\grid\Column
renderFooterCell() フッターセルをレンダリングします。 yii\grid\Column
renderHeaderCell() ヘッダーセルをレンダリングします。 yii\grid\Column

保護されたメソッド

継承されたメソッドを非表示

メソッド 説明 定義元
getHeaderCellLabel() ヘッダーセルのラベルを返します。 yii\grid\DataColumn
renderDataCellContent() データセルのコンテンツをレンダリングします。 yii\grid\DataColumn
renderFilterCellContent() フィルタセルのコンテンツをレンダリングします。 yii\grid\DataColumn
renderFooterCellContent() フッターセルのコンテンツをレンダリングします。 yii\grid\Column
renderHeaderCellContent() ヘッダーセルのコンテンツをレンダリングします。 yii\grid\DataColumn

プロパティの詳細

継承されたプロパティを非表示

$attribute public property

この列に関連付けられた属性名。$content$valueも指定されていない場合、指定された属性の値が各データモデルから取得され、表示されます。

また、$label が指定されていない場合、属性に関連付けられたラベルが表示されます。

public string $attribute null
$enableSorting public property

この列でソートを許可するかどうか。true の場合、かつ $attributeyii\grid\GridView::$dataProvider のソート定義に見つかった場合、この列のヘッダーセルには、クリックするとソートをトリガーできるリンクが含まれます。

public boolean $enableSorting true
$encodeLabel public property (バージョン 2.0.1 から利用可能)

ヘッダーラベルをHTMLエンコードするかどうか。

$labelも参照してください。

public boolean $encodeLabel true
$filter public property

このデータ列に使用されるフィルター入力(テキストフィールド、ドロップダウンリストなど)を表すHTMLコード。このプロパティは、yii\grid\GridView::$filterModel が設定されている場合にのみ有効です。

  • このプロパティが設定されていない場合、$filterInputOptionsで定義された属性を持つテキストフィールドがフィルター入力として生成されます。yii\helpers\BaseHtml::activeInput()を参照して、アクティブな入力タグがどのように生成されるかを確認してください。
  • このプロパティが配列の場合、このプロパティの値をリストオプションとして使用するドロップダウンリストが生成されます。
  • このデータ列にフィルターを適用したくない場合は、この値をfalseに設定します。
public string|array|null|false $filter null
$filterAttribute public property (バージョン 2.0.41 から利用可能)

この列に関連付けられたyii\grid\GridView::$filterModelの属性名。設定されていない場合、$attributeと同じ値になります。

$filterInputOptions public property

フィルター入力フィールドのHTML属性。このプロパティは、$filterプロパティと組み合わせて使用されます。$filterが設定されていないか、配列の場合、このプロパティを使用して生成されたフィルター入力フィールドのHTML属性がレンダリングされます。

デフォルト値の空のidは、idがモデル属性から取得されないようにし、パフォーマンスを向上させます。

yii\helpers\Html::renderTagAttributes()を参照して、属性がどのようにレンダリングされるかを確認してください。

public array $filterInputOptions = [
    
'class' => 'form-control',
    
'id' => null,
]
$format public property

各データモデルの値をどの形式で表示するか(例:"raw""text""html"['date', 'php:Y-m-d'])。サポートされる形式は、yii\grid\GridViewで使用されるformatterによって決定されます。デフォルトの形式は"text"で、yii\i18n\FormatterがGridViewのformatterとして使用される場合、値はHTMLエンコードされたプレーンテキストとしてフォーマットされます。

yii\i18n\Formatter::format()も参照してください。

public string|array|Closure $format 'text'
$label public property

ヘッダーセルに表示されるラベル、およびこの列のソートが有効になっている場合のソートリンクラベルとしても使用されます。設定されておらず、GridViewのデータプロバイダーによって提供されるモデルがyii\db\ActiveRecordのインスタンスである場合、ラベルはyii\db\ActiveRecord::getAttributeLabel()を使用して決定されます。それ以外の場合は、yii\helpers\Inflector::camel2words()を使用してラベルを取得します。

public string|null $label null
$sortLinkOptions public property

この列のソートが有効になっている場合、yii\data\Sort::link()によって生成されるヘッダーセルのリンクタグのHTML属性。

yii\helpers\Html::renderTagAttributes()を参照して、属性がどのようにレンダリングされるかを確認してください。

public array $sortLinkOptions = []
$value public property

現在の列に表示する値を決定するために使用される無名関数または文字列。

これが無名関数の場合、各行に対して呼び出され、戻り値が各データモデルの表示値として使用されます。この関数のシグネチャは次のようになります。function ($model, $key, $index, $column)。ここで、$model$key$indexは、現在レンダリングされている行のモデル、キー、インデックスを表し、$columnyii\grid\DataColumnオブジェクトへの参照です。

このプロパティを、この列に表示する属性名を表す文字列に設定することもできます。これは、表示する属性が、ソートとフィルタリングに使用される$attributeと異なる場合に使用できます。

設定されていない場合、$model[$attribute]を使用して値が取得されます。ここで、$attribute$attributeの値です。

public string|Closure|null $value null

メソッドの詳細

継承されたメソッドを非表示

__call() publicメソッド

定義位置: yii\base\BaseObject::__call()

クラスメソッドではない名前付きメソッドを呼び出します。

これはPHPのマジックメソッドであり、不明なメソッドが呼び出された際に暗黙的に呼び出されるため、直接呼び出さないでください。

public mixed __call ( $name, $params )
$name string

メソッド名

$params array

メソッドパラメータ

戻り値 mixed

メソッドの戻り値

例外 yii\base\UnknownMethodException

不明なメソッドを呼び出した場合

                public function __call($name, $params)
{
    throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}

            
__construct() publicメソッド

定義位置: yii\base\BaseObject::__construct()

コンストラクタ。

デフォルトの実装では、次の2つのことを行います。

  • 与えられた設定$configを使用してオブジェクトを初期化します。
  • init()を呼び出します。

このメソッドを子クラスでオーバーライドする場合は、

  • コンストラクタの最後の引数を、ここにある$configのように、設定配列にすることをお勧めします。
  • コンストラクタの最後に親の実装を呼び出してください。
public void __construct ( $config = [] )
$config array

オブジェクトのプロパティを初期化するために使用される、名前と値のペア

                public function __construct($config = [])
{
    if (!empty($config)) {
        Yii::configure($this, $config);
    }
    $this->init();
}

            
__get() publicメソッド

定義位置: yii\base\BaseObject::__get()

オブジェクトプロパティの値を返します。

これはPHPのマジックメソッドであり、$value = $object->property;を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

こちらも参照してください __set().

public mixed __get ( $name )
$name string

プロパティ名

戻り値 mixed

プロパティ値

例外 yii\base\UnknownPropertyException

プロパティが定義されていない場合

例外 yii\base\InvalidCallException

プロパティが書き込み専用の場合

                public function __get($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter();
    } elseif (method_exists($this, 'set' . $name)) {
        throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
    }
    throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}

            
__isset() publicメソッド

定義位置: yii\base\BaseObject::__isset()

プロパティが設定されているかどうか(定義されていてnullでない)を確認します。

これはPHPのマジックメソッドであり、isset($object->property)を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

プロパティが定義されていない場合は、falseが返されることに注意してください。

こちらも参照してください https://www.php.net/manual/en/function.isset.php.

public boolean __isset ( $name )
$name string

プロパティ名またはイベント名

戻り値 boolean

指定されたプロパティが設定されているかどうか(nullでないか)。

                public function __isset($name)
{
    $getter = 'get' . $name;
    if (method_exists($this, $getter)) {
        return $this->$getter() !== null;
    }
    return false;
}

            
__set() publicメソッド

定義位置: yii\base\BaseObject::__set()

オブジェクトプロパティの値を設定します。

これはPHPのマジックメソッドであり、$object->property = $value;を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

こちらも参照してください __get().

public void __set ( $name, $value )
$name string

プロパティ名またはイベント名

$value mixed

プロパティ値

例外 yii\base\UnknownPropertyException

プロパティが定義されていない場合

例外 yii\base\InvalidCallException

プロパティが読み取り専用の場合

                public function __set($name, $value)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter($value);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
    } else {
        throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
    }
}

            
__unset() publicメソッド

定義位置: yii\base\BaseObject::__unset()

オブジェクトプロパティをnullに設定します。

これはPHPのマジックメソッドであり、unset($object->property)を実行した際に暗黙的に呼び出されるため、直接呼び出さないでください。

プロパティが定義されていない場合は、このメソッドは何もしません。プロパティが読み取り専用の場合は、例外をスローします。

こちらも参照してください https://www.php.net/manual/en/function.unset.php.

public void __unset ( $name )
$name string

プロパティ名

例外 yii\base\InvalidCallException

プロパティが読み取り専用の場合。

                public function __unset($name)
{
    $setter = 'set' . $name;
    if (method_exists($this, $setter)) {
        $this->$setter(null);
    } elseif (method_exists($this, 'get' . $name)) {
        throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
    }
}

            
canGetProperty() publicメソッド

定義位置: yii\base\BaseObject::canGetProperty()

プロパティを読み取ることができるかどうかを示す値を返します。

プロパティは、以下の場合に読み取り可能です。

  • クラスに、指定された名前に関連付けられたゲッターメソッドがある場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスに、指定された名前のメンバ変数がある場合($checkVarsがtrueの場合)。

こちらも参照してください canSetProperty().

public boolean canGetProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティを読み取ることができるかどうか

                public function canGetProperty($name, $checkVars = true)
{
    return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}

            
canSetProperty() publicメソッド

定義位置: yii\base\BaseObject::canSetProperty()

プロパティを設定できるかどうかを示す値を返します。

プロパティは、以下の場合に書き込み可能です。

  • クラスに、指定された名前に関連付けられたセッターメソッドがある場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスに、指定された名前のメンバ変数がある場合($checkVarsがtrueの場合)。

こちらも参照してください canGetProperty().

public boolean canSetProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティを書き込むことができるかどうか

                public function canSetProperty($name, $checkVars = true)
{
    return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}

            
className() public staticメソッド
2.0.14以降非推奨。PHP >= 5.5では、代わりに::classを使用してください。

定義位置: yii\base\BaseObject::className()

このクラスの完全修飾名を返します。

public static string className ( )
戻り値 string

このクラスの完全修飾名。

                public static function className()
{
    return get_called_class();
}

            
getDataCellValue() publicメソッド

データセルの値を返します。

public string getDataCellValue ( $model, $key, $index )
$model mixed

データモデル

$key mixed

データモデルに関連付けられたキー

$index integer

yii\grid\GridView::$dataProviderによって返されるモデル配列の中で、データモデルの0ベースのインデックス。

戻り値 string

データセルの値

                public function getDataCellValue($model, $key, $index)
{
    if ($this->value !== null) {
        if (is_string($this->value)) {
            return ArrayHelper::getValue($model, $this->value);
        }
        return call_user_func($this->value, $model, $key, $index, $this);
    } elseif ($this->attribute !== null) {
        return ArrayHelper::getValue($model, $this->attribute);
    }
    return null;
}

            
getHeaderCellLabel() protectedメソッド (バージョン2.0.8以降で使用可能)

ヘッダーセルのラベルを返します。

このメソッドは、ヘッダーセルのラベルをカスタマイズするためにオーバーライドできます。

protected string getHeaderCellLabel ( )
戻り値 string

ラベル

                protected function getHeaderCellLabel()
{
    $provider = $this->grid->dataProvider;
    if ($this->label === null) {
        if ($this->attribute === null) {
            $label = '';
        } elseif ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQueryInterface) {
            /* @var $modelClass Model */
            $modelClass = $provider->query->modelClass;
            $model = $modelClass::instance();
            $label = $model->getAttributeLabel($this->attribute);
        } elseif ($provider instanceof ArrayDataProvider && $provider->modelClass !== null) {
            /* @var $modelClass Model */
            $modelClass = $provider->modelClass;
            $model = $modelClass::instance();
            $label = $model->getAttributeLabel($this->attribute);
        } elseif ($this->grid->filterModel !== null && $this->grid->filterModel instanceof Model) {
            $label = $this->grid->filterModel->getAttributeLabel($this->filterAttribute);
        } 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 $label;
}

            
hasMethod() publicメソッド

定義されている場所: yii\base\BaseObject::hasMethod()

メソッドが定義されているかどうかを示す値を返します。

デフォルトの実装は、PHP関数method_exists()の呼び出しです。PHPマジックメソッド__call()を実装した場合は、このメソッドをオーバーライドできます。

public boolean hasMethod ( $name )
$name string

メソッド名

戻り値 boolean

メソッドが定義されているかどうか

                public function hasMethod($name)
{
    return method_exists($this, $name);
}

            
hasProperty() publicメソッド

定義されている場所: yii\base\BaseObject::hasProperty()

プロパティが定義されているかどうかを示す値を返します。

プロパティは、以下の場合に定義されています。

  • クラスが指定された名前と関連付けられたゲッターまたはセッターメソッドを持っている場合(この場合、プロパティ名はケースインセンシティブです)。
  • クラスに、指定された名前のメンバ変数がある場合($checkVarsがtrueの場合)。

参照

public boolean hasProperty ( $name, $checkVars true )
$name string

プロパティ名

$checkVars boolean

メンバ変数をプロパティとして扱うかどうか

戻り値 boolean

プロパティが定義されているかどうか

                public function hasProperty($name, $checkVars = true)
{
    return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}

            
init() publicメソッド

オブジェクトを初期化します。

このメソッドは、オブジェクトが指定された構成で初期化された後、コンストラクタの最後に呼び出されます。

public void init ( )

                public function init()
{
    parent::init();
    if ($this->filterAttribute === null) {
        $this->filterAttribute = $this->attribute;
    }
}

            
renderDataCell() publicメソッド

定義されている場所: yii\grid\Column::renderDataCell()

データセルをレンダリングします。

public string renderDataCell ( $model, $key, $index )
$model mixed

レンダリングされるデータモデル

$key mixed

データモデルに関連付けられたキー

$index integer

yii\grid\GridView::$dataProviderによって返されるアイテム配列における、データアイテムのゼロベースインデックス。

戻り値 string

レンダリング結果

                public function renderDataCell($model, $key, $index)
{
    if ($this->contentOptions instanceof Closure) {
        $options = call_user_func($this->contentOptions, $model, $key, $index, $this);
    } else {
        $options = $this->contentOptions;
    }
    return Html::tag('td', $this->renderDataCellContent($model, $key, $index), $options);
}

            
renderDataCellContent() protectedメソッド

データセルのコンテンツをレンダリングします。

protected string renderDataCellContent ( $model, $key, $index )
$model mixed

データモデル

$key mixed

データモデルに関連付けられたキー

$index integer

yii\grid\GridView::$dataProviderによって返されるモデル配列の中で、データモデルの0ベースのインデックス。

戻り値 string

レンダリング結果

                protected function renderDataCellContent($model, $key, $index)
{
    if ($this->content === null) {
        return $this->grid->formatter->format($this->getDataCellValue($model, $key, $index), $this->format);
    }
    return parent::renderDataCellContent($model, $key, $index);
}

            
renderFilterCell() publicメソッド

定義されている場所: yii\grid\Column::renderFilterCell()

フィルタセルをレンダリングします。

public void renderFilterCell ( )

                public function renderFilterCell()
{
    return Html::tag('td', $this->renderFilterCellContent(), $this->filterOptions);
}

            
renderFilterCellContent() protectedメソッド

フィルタセルのコンテンツをレンダリングします。

デフォルトの実装は単にスペースをレンダリングします。このメソッドをオーバーライドして、フィルターセルのレンダリングをカスタマイズできます(存在する場合)。

protected string renderFilterCellContent ( )
戻り値 string

レンダリング結果

                protected function renderFilterCellContent()
{
    if (is_string($this->filter)) {
        return $this->filter;
    }
    $model = $this->grid->filterModel;
    if ($this->filter !== false && $model instanceof Model && $this->filterAttribute !== null && $model->isAttributeActive($this->filterAttribute)) {
        if ($model->hasErrors($this->filterAttribute)) {
            Html::addCssClass($this->filterOptions, 'has-error');
            $error = ' ' . Html::error($model, $this->filterAttribute, $this->grid->filterErrorOptions);
        } else {
            $error = '';
        }
        if (is_array($this->filter)) {
            $options = array_merge(['prompt' => '', 'strict' => true], $this->filterInputOptions);
            return Html::activeDropDownList($model, $this->filterAttribute, $this->filter, $options) . $error;
        } elseif ($this->format === 'boolean') {
            $options = array_merge(['prompt' => '', 'strict' => true], $this->filterInputOptions);
            return Html::activeDropDownList($model, $this->filterAttribute, [
                1 => $this->grid->formatter->booleanFormat[1],
                0 => $this->grid->formatter->booleanFormat[0],
            ], $options) . $error;
        }
        $options = array_merge(['maxlength' => true], $this->filterInputOptions);
        return Html::activeTextInput($model, $this->filterAttribute, $options) . $error;
    }
    return parent::renderFilterCellContent();
}

            
renderFooterCell() publicメソッド

定義されている場所: yii\grid\Column::renderFooterCell()

フッターセルをレンダリングします。

public void renderFooterCell ( )

                public function renderFooterCell()
{
    return Html::tag('td', $this->renderFooterCellContent(), $this->footerOptions);
}

            
renderFooterCellContent() protectedメソッド

定義されている場所: yii\grid\Column::renderFooterCellContent()

フッターセルのコンテンツをレンダリングします。

デフォルトの実装は単に$footerをレンダリングします。このメソッドをオーバーライドして、フッターセルのレンダリングをカスタマイズできます。

protected string renderFooterCellContent ( )
戻り値 string

レンダリング結果

                protected function renderFooterCellContent()
{
    return $this->footer !== null && trim($this->footer) !== '' ? $this->footer : $this->grid->emptyCell;
}

            
renderHeaderCell() publicメソッド

定義されている場所: yii\grid\Column::renderHeaderCell()

ヘッダーセルをレンダリングします。

public void renderHeaderCell ( )

                public function renderHeaderCell()
{
    return Html::tag('th', $this->renderHeaderCellContent(), $this->headerOptions);
}

            
renderHeaderCellContent() protectedメソッド

ヘッダーセルのコンテンツをレンダリングします。

デフォルトの実装は単に$headerをレンダリングします。このメソッドをオーバーライドして、ヘッダーセルのレンダリングをカスタマイズできます。

protected string renderHeaderCellContent ( )
戻り値 string

レンダリング結果

                protected function renderHeaderCellContent()
{
    if ($this->header !== null || $this->label === null && $this->attribute === null) {
        return parent::renderHeaderCellContent();
    }
    $label = $this->getHeaderCellLabel();
    if ($this->encodeLabel) {
        $label = Html::encode($label);
    }
    if (
        $this->attribute !== null && $this->enableSorting &&
        ($sort = $this->grid->dataProvider->getSort()) !== false && $sort->hasAttribute($this->attribute)
    ) {
        return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => $label]));
    }
    return $label;
}