zii.widgets.grid.CGridView Style

Dears,

I have a zii.widgets.grid.CGridView bind to a model at form that generates from GII,

All I need to do that how can I give colors to the grid row according to a model filed, it’s like color coding for the grid rows.

Here you are my code

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

'id'=&gt;'events-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


'columns'=&gt;array(


	'EVENT_ID',


	'EVENT_DESC',


	'EVENT_MANAGER_ID',


	'EVENTTYPE_ID',


	'EXPECTEDNO',


	'FROMDATE',


	'STATUS_ID',


	array(


		'class'=&gt;'CButtonColumn',


	),


),

)); ?>

According the value of ‘STATUS_ID’ I need to set a color, How?

please help :)

Is this what you want ?


<style>

    .red {background: red}

    .green {background: green}

</style>


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

	'id'=>'page-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

        'rowCssClassExpression' => '$data->status==="3"?"red":"green"',

...

...

?>

It’s working…

many thanks for you Rookie.

but if there is more than one value, how can I code that expression (status values 1,2,3,…)

these values comes from the database, and the colors as well.

do we have a solution for it

again, many thanks for your help

Yes there’s a solution: use some common sense, research a little, its pretty easy… or you want me to have this assignment done for you? ;)

sure nvm, I’ll do it my self

Good, thats how you learn…

why you use $data not $model