CGridView - Highlighting Data


I have used CGridView to show my result set. Following the 1 column of my data.



Kunal Parikh========2012-01-27========2012-01-27

Chintan Shah========2012-01-28========2012-01-28

Chintan Shah========2012-02-09========2012-02-11

Vijay Aluguvelli========2012-02-04========2012-02-04

Chintan Shah========2012-02-03========2012-02-03

Nimesh Prajapati========2012-02-29========2012-02-29

Harshal Shah EMP========2012-06-01========2012-06-10

Nimesh Prajapati========2012-01-23========2012-01-31

Nimesh Prajapati========2012-01-26========2012-01-26

Now I want to do like if From or To date is greater than today then apply bold tag to From and To Date.

Can i do it, thru CGridView?

You should be able to use the cssClassExpression property of CDataColumn. For each row you will have access to $data-from and $data->to for the comparison. You can use a trinary operator in an inline expression (as usual surrounded by quotes to suit eval) and/or call an external function, eg $data->someMethod().

Edit: if not eval’d, callback syntax will be array($data, ‘someMethod’) but I think it’s not a good idea to return css content from the model.


Hello tri, Thanks for the reply. Solved that issue by the model method, as I have to do some calculation related to date, which I think not possible by ternary operator.