Change the background-color of a row in a CGridView

Hello everyone,

I would like the title says that according to a condition, the background color of a row in a CGridview change.

So I tried with rowCssClass or rowCssStyleExpression without success.

What do you recommend??

The condition is to define it in the widget or before?

You need to modify CGridView’s css file. Copy the CSS folder from the framework directory (framework\zii\widgets\assets\gridview) to your local folder structure. CGridView has a cssFile property to point to the new file. There, you can change the row colors for odd/even & :hover.

http://www.yiiplayground.cubedwater.com/index.php?r=UiModule/dataview/gridStyle

Cheers,

Matt

This should work… can you post your code… how did you set those attributes?