CGridView rowCssClassExpression

Any idea how I can use CGridView rowCssClassExpression? I realise it’s a PHP expression, however when I try something like this, I get the TR class set to “row-closed” no matter what the value of “open_ticket”.




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

	'dataProvider'=>$dataProvider,

	'showTableOnEmpty'=>true,

	'emptyText'=>'This ticket folder is empty. ',

	'rowCssClassExpression'=>'$data->open_ticked?"row-open":"row-closed"',

	'columns'=>array(

		array(

			'class'=>'CCheckBoxColumn',

			'name'=>'delete',

			'value'=>'$data->id',

			'id'=>'delete'

		),

		array(

			'name'=>'subject.value',

			'header'=>'Subject',

			'value'=>'CHtml::link($data->subject->value, array("ticket/read", "id"=>$data->id)',

			'type'=>'raw'

		),

		array(

			'class'=>'CButtonColumn'

		),

	),

));



anyone? - bump

You cannot use $data variable. You need to use $this->dataProvider->data[$row] to refer to the model associated with the row.

I just added support so that you can use $data directly in the expression.

thanks qiang - you star!

I probed this solution and not rules. Only rules:




'rowCssClassExpression'=>'$data["open_ticked"]?"row-open":"row-closed"',