Hello,
I am attempting to assign a specific class to a table cell based on the cells content, however my evaluation is rendering incorrectly. Also, being a noob to Yii, I’m probably putting adding this code in the wrong place (CGridColumn.php) so a recomendation there is also appreciated. What is being returned is the entire row of cells is assigned the css class, yet only 4 of the 14 cells should return the class. Thanks for any help.
public function renderDataCell($row)
{
$data=$this->grid->dataProvider->data[$row];
$options=$this->htmlOptions;
if($this->cssClassExpression!==null)
{
$class=$this->evaluateExpression($this->cssClassExpression,array('row'=>$row,'data'=>$data));
if(isset($options['class']))
$options['class'].=' '.$class;
else
$options['class']=$class;
}
foreach ($data as $field)
{
if($field==='XXX') //my attempt to change the rdo table cell color
$tdrdocell = 'td class="rdo"'; //my attempt to change the rdo table cell color
else //my attempt to change the rdo table cell color
$tdrdocell = 'td'; //my attempt to change the rdo table cell color
}
echo CHtml::openTag($tdrdocell,$options);
$this->renderDataCellContent($row,$data);
echo '</td>';
}