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







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


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?









Try it like this :)

This did not work also


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