Cgridview Cells Different Color Based On Value

Sorry if this has been asked and answered before, but I’m guessing this is a common requirement and I have not been able to find the answer, spelled out.

The requirement is simply this:

Based on the value in a CGridView widget cell (column/row), change the background color of just that cell.

I’m guessing something like this is part of the solution:

‘htmlOptions’=>array(

     'style'=>'background:#6ca5d1;color:#ffffff;  

where the hex value is the color you want, but I don’t know how to add the conditional based on the cell value.

I used giix to create the view, so here is the code for one of the columns (the status of a project request). How do I alter it to add conditional background color coding? Ideally, I’d like it to be green, yellow, or red, based on its value. Thanks for any help anyone can offer!

	array(


	'name'=>'project_req_status',


	'value'=>'GxHtml::valueEx($data->projectReqStatus)',


	'filter'=>GxHtml::listDataEx(ProjectStatus::model()->findAllAttributes(null, true)),


			),

A friend of mine solved it (showing both raw table data and fk dropdown values)

(usegreenback-class-id is in main.css and sets background to green):

array(

            'name'=>'project_req_status',


            'value'=>'GxHtml::valueEx($data->projectReqStatus)',


            'filter'=>GxHtml::listDataEx(ProjectStatus::model()->findAllAttributes(null, true)),


            'cssClassExpression'=> function($row, $data) {


   //       switch($data->project_req_status) {


            switch(GxHtml::valueEx($data->projectReqStatus)) {


            case 'COMPLETE':


                return 'usegreenback-class-id';


            case 'IN-PROGRESS':


                return 'useyellowback-class-id';


            default:


               return '';


                 }   


                 }   





            ),