$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'
),
),
));
Page 1 of 1
CGridView rowCssClassExpression
#1
Posted 25 February 2010 - 09:39 AM
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".
#3
Posted 26 February 2010 - 12:00 AM
You cannot use $data variable. You need to use $this->dataProvider->data[$row] to refer to the model associated with the row.
#4
Posted 26 February 2010 - 12:04 AM
I just added support so that you can use $data directly in the expression.
#6
Posted 22 March 2013 - 03:58 AM
I probed this solution and not rules. Only rules:
'rowCssClassExpression'=>'$data["open_ticked"]?"row-open":"row-closed"',
Share this topic:
Page 1 of 1

Help












