adjusted the default Grid column classes to changes made in #2052

use get...Content() instead of render...Content()
This commit is contained in:
Carsten Brandt
2013-09-04 17:24:49 +02:00
parent dba20dbef5
commit 34057b1df1
4 changed files with 48 additions and 43 deletions

View File

@@ -305,13 +305,15 @@ EOD;
}
/**
* Renders the data cell content.
* Returns the data cell content.
* This method renders the view, update and delete buttons in the data cell.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
* @return string the data cell content.
* @since 1.1.15
*/
protected function renderDataCellContent($row,$data)
public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
$tr=array();
ob_start();
foreach($this->buttons as $id=>$button)
@@ -321,7 +323,7 @@ EOD;
ob_clean();
}
ob_end_clean();
echo strtr($this->template,$tr);
return strtr($this->template,$tr);
}
/**

View File

@@ -187,43 +187,39 @@ EOD;
}
/**
* Renders the header cell content.
* Returns the header cell content.
* This method will render a checkbox in the header when {@link selectableRows} is greater than 1
* or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1.
* @return string the header cell content.
* @since 1.1.15
*/
protected function renderHeaderCellContent()
public function getHeaderCellContent()
{
if(trim($this->headerTemplate)==='')
{
echo $this->grid->blankDisplay;
return;
}
return $this->grid->blankDisplay;
$item = '';
if($this->selectableRows===null && $this->grid->selectableRows>1)
$item = CHtml::checkBox($this->id.'_all',false,array('class'=>'select-on-check-all'));
$item=CHtml::checkBox($this->id.'_all',false,array('class'=>'select-on-check-all'));
elseif($this->selectableRows>1)
$item = CHtml::checkBox($this->id.'_all',false);
$item=CHtml::checkBox($this->id.'_all',false);
else
{
ob_start();
parent::renderHeaderCellContent();
$item = ob_get_clean();
}
$item=parent::getHeaderCellContent();
echo strtr($this->headerTemplate,array(
return strtr($this->headerTemplate,array(
'{item}'=>$item,
));
}
/**
* Renders the data cell content.
* Returns the data cell content.
* This method renders a checkbox in the data cell.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
* @return string the data cell content.
* @since 1.1.15
*/
protected function renderDataCellContent($row,$data)
public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
if($this->value!==null)
$value=$this->evaluateExpression($this->value,array('data'=>$data,'row'=>$row));
elseif($this->name!==null)
@@ -243,6 +239,6 @@ EOD;
unset($options['name']);
$options['value']=$value;
$options['id']=$this->id.'_'.$row;
echo CHtml::checkBox($name,$checked,$options);
return CHtml::checkBox($name,$checked,$options);
}
}

View File

@@ -85,54 +85,59 @@ class CDataColumn extends CGridColumn
}
/**
* Renders the filter cell content.
* This method will render the {@link filter} as is if it is a string.
* Returns the filter cell content.
* This method will return the {@link filter} as is if it is a string.
* If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered.
* Otherwise if {@link filter} is not false, a text field is rendered.
* @since 1.1.1
* @return string the filter cell content
* @since 1.1.15
*/
protected function renderFilterCellContent()
public function getFilterCellContent()
{
if(is_string($this->filter))
echo $this->filter;
return $this->filter;
elseif($this->filter!==false && $this->grid->filter!==null && $this->name!==null && strpos($this->name,'.')===false)
{
if(is_array($this->filter))
echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id'=>false,'prompt'=>''));
return CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id'=>false,'prompt'=>''));
elseif($this->filter===null)
echo CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false));
return CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false));
}
else
parent::renderFilterCellContent();
return parent::getFilterCellContent();
}
/**
* Renders the header cell content.
* Returns the header cell content.
* This method will render a link that can trigger the sorting if the column is sortable.
* @return string the header cell content.
* @since 1.1.15
*/
protected function renderHeaderCellContent()
public function getHeaderCellContent()
{
if($this->grid->enableSorting && $this->sortable && $this->name!==null)
echo $this->grid->dataProvider->getSort()->link($this->name,$this->header,array('class'=>'sort-link'));
return $this->grid->dataProvider->getSort()->link($this->name,$this->header,array('class'=>'sort-link'));
elseif($this->name!==null && $this->header===null)
{
if($this->grid->dataProvider instanceof CActiveDataProvider)
echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
return CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
else
echo CHtml::encode($this->name);
return CHtml::encode($this->name);
}
else
parent::renderHeaderCellContent();
return parent::getHeaderCellContent();
}
/**
* Renders the data cell content.
* Returns the data cell content.
* This method evaluates {@link value} or {@link name} and renders the result.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
* @return string the data cell content.
* @since 1.1.15
*/
protected function renderDataCellContent($row,$data)
public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
if($this->value!==null)
$value=$this->evaluateExpression($this->value,array('data'=>$data,'row'=>$row));
elseif($this->name!==null)

View File

@@ -87,13 +87,15 @@ class CLinkColumn extends CGridColumn
public $linkHtmlOptions=array();
/**
* Renders the data cell content.
* Returns the data cell content.
* This method renders a hyperlink in the data cell.
* @param integer $row the row number (zero-based)
* @param mixed $data the data associated with the row
* @return string the data cell content.
* @since 1.1.15
*/
protected function renderDataCellContent($row,$data)
public function getDataCellContent($row)
{
$data=$this->grid->dataProvider->data[$row];
if($this->urlExpression!==null)
$url=$this->evaluateExpression($this->urlExpression,array('data'=>$data,'row'=>$row));
else