mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-21 00:54:53 +08:00
Raw content return for Grid DataColumn & Column
Need to have a method `getDataCellContent` to return raw parsed data cell content. This is useful when extending these Columns, for processing any other data before formatting via `renderDataCellContent`.
This commit is contained in:
@@ -114,6 +114,22 @@ class Column extends Object
|
|||||||
{
|
{
|
||||||
return trim($this->footer) !== '' ? $this->footer : $this->grid->emptyCell;
|
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.
|
* Renders the data cell content.
|
||||||
@@ -124,11 +140,7 @@ class Column extends Object
|
|||||||
*/
|
*/
|
||||||
protected function renderDataCellContent($model, $key, $index)
|
protected function renderDataCellContent($model, $key, $index)
|
||||||
{
|
{
|
||||||
if ($this->content !== null) {
|
return ($this->content !== null) ? $this->getDataCellContent : $this->grid->emptyCell;
|
||||||
return call_user_func($this->content, $model, $key, $index, $this);
|
|
||||||
} else {
|
|
||||||
return $this->grid->emptyCell;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user