Pass a variable to htmlOptions in CGridview

How do I pass a variable to htmlOptions in CGrisView? I wish to color-code a number:

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










			'htmlOptions'=>array('style'=>'text-align:right; color:$data->amount_color'),


doesn’t work, and neither does

'htmlOptions'=>array('style'=>'text-align:right; color:'.$data->amount_color),

What am I doing wrong?

Figured it out - should have been doing this:

'htmlOptions'=>array('style'=>'text-align:right; color:'.$model->amount_color),

The problem is it encodes the whole column, when I want to do code each cell individually. I suppose I have to put html into the value field?

this way works:







.red {color: red;} 

.green {color: green;} 

.blue {color: blue;} 


probably there is a better way

Is there any way to pass $data to array in htmlOptions?? I need id of data in selected row to create ajax link.

















#amorang : I use this

'cssClassExpression'=>'$data->amount_color==\'red\' ? \'selected_row\' : \'\' '   //css class name


better use harcode link in value :


'value'=>'"<a href=\"#\" onclick=\"\">Update</a>"'

although it’s a bit rude…

Thanks, that works great!

hello deimos, do you has solved this problems?? becouse i have same problems with u.