[solved] CGridView htmlOptions

Hi guys,

i want to format a value in the grid according to another row value, like:




$this->widget('zii.widgets.grid.CGridView', array(

		'id' => 'events-grid',

		'dataProvider' => $dataProvider,

		'columns' => array(

			array(

			'name' => 'event',

			'value' => '$data->text;',

			//if $data->isread format string e.g. bold (line 23)

			'htmlOptions' => ($data->isread) ? array('style'=>'font-weight:bold') : array(),

			'header' => 'Event',

			),

		),

));



This approach does not work, but i get the error:

Notice: Undefined variable: data in D:\dev\ciprojects\oya_yii\protected\views\events\index.php on line 23

Is there any possible way in a gridView to format the data based on the content?

TIA

Marco

You can use cssClassExpression




 'cssClassExpression' => "(\$data->isread) ? 'textRead' :''",




And then edit your css:




td.isread

{

   font-weight:bold;

}



That works great.

Thank you zaccaria.