yii\grid\DataColumn::getDataCellValue PHP Method

getDataCellValue() public method

Returns the data cell value.
public getDataCellValue ( mixed $model, mixed $key, integer $index ) : string
$model mixed the data model
$key mixed the key associated with the data model
$index integer the zero-based index of the data model among the models array returned by [[GridView::dataProvider]].
return string the data cell value
    public function getDataCellValue($model, $key, $index)
    {
        if ($this->value !== null) {
            if (is_string($this->value)) {
                return ArrayHelper::getValue($model, $this->value);
            } else {
                return call_user_func($this->value, $model, $key, $index, $this);
            }
        } elseif ($this->attribute !== null) {
            return ArrayHelper::getValue($model, $this->attribute);
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function getDataCellValue($model, $key, $index)
 {
     if ($this->value !== null) {
         return parent::getDataCellValue($model, $key, $index);
     } else {
         $class = $this->menuClass;
         return $class::create(['model' => $model])->render(MenuButton::class);
     }
 }
All Usage Examples Of yii\grid\DataColumn::getDataCellValue