mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Merge pull request #2284 from kartik-v/patch-12
Raw content return for Grid DataColumn & Column
This commit is contained in:
@ -115,6 +115,22 @@ class Column extends Object
|
||||
return trim($this->footer) !== '' ? $this->footer : $this->grid->emptyCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw data cell content.
|
||||
* @param mixed $model the data model
|
||||
* @param mixed $key the key associated with the data model
|
||||
* @param integer $index the zero-based index of the data model among the models array returned by [[GridView::dataProvider]].
|
||||
* @return string the rendering result
|
||||
*/
|
||||
protected function getDataCellContent($model, $key, $index)
|
||||
{
|
||||
if ($this->content !== null) {
|
||||
return call_user_func($this->content, $model, $key, $index, $this);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the data cell content.
|
||||
* @param mixed $model the data model
|
||||
@ -124,11 +140,7 @@ class Column extends Object
|
||||
*/
|
||||
protected function renderDataCellContent($model, $key, $index)
|
||||
{
|
||||
if ($this->content !== null) {
|
||||
return call_user_func($this->content, $model, $key, $index, $this);
|
||||
} else {
|
||||
return $this->grid->emptyCell;
|
||||
}
|
||||
return ($this->content !== null) ? $this->getDataCellContent($model, $key, $index) : $this->grid->emptyCell;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,9 +136,9 @@ class DataColumn extends Column
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* Return raw content
|
||||
*/
|
||||
protected function renderDataCellContent($model, $key, $index)
|
||||
protected function getDataCellContent($model, $key, $index)
|
||||
{
|
||||
if ($this->value !== null) {
|
||||
if (is_string($this->value)) {
|
||||
@ -149,8 +149,16 @@ class DataColumn extends Column
|
||||
} elseif ($this->content === null && $this->attribute !== null) {
|
||||
$value = ArrayHelper::getValue($model, $this->attribute);
|
||||
} else {
|
||||
return parent::renderDataCellContent($model, $key, $index);
|
||||
return parent::getDataCellContent($model, $key, $index);
|
||||
}
|
||||
return $this->grid->formatter->format($value, $this->format);
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function renderDataCellContent($model, $key, $index)
|
||||
{
|
||||
return $this->grid->formatter->format($this->getDataCellContent($model, $key, $index), $this->format);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user