How To Write If Statement In Cdatacolumn Value?

Hi there, I am working on CgridView in which i want to render student results. Now i have an attribute named status so i write like this in column

$gridColumn=array(


array(

'Header'=>'Result',

'name'=>'status'

)

)

This works great but I need to check whether this student is pass or Fail so depending upon the result the color of the cell would be changed. Now i tried to use property


"value"

of CDataColumn but when i wrote it in if statement it gave error.

when i tried to change htmlOptions depending upon result like this


'htmlOptions'=>('$data->status'=="FAIL")? array('style'=>'background-color:red'):''

It always return false.

Official document says about this property that

type= string

description=a PHP expression that will be evaluated for every data cell using evaluateExpression and whose result will be rendered as the content of the data cell.

Now my question is that how to set htmlOptions depending upon status?

Hi,

‘cssClassExpression’=>’$data->status==“FAIL”?“red”:“green”’,

.red{

background-color:red;

}

.green{

background-color:green;

}

Try it like this :)

This did not work also

Hi,

This was tested code… its works perfectly in my project… just check again… or post your code