Quantcast
Channel: Shani's Php CookBook
Viewing all articles
Browse latest Browse all 60

PHP YII Change the Row Color Based on the Column value in CGridView [rowCssClassExpression]

$
0
0

Belows is how you can use CGridView 'rowCssClassExpression' to change row color based on a column's value:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'rowCssClassExpression'=>'($data->column_name==0)?"new":"old"',
'columns'=>array(
...
),
));
You can also call a custom php function, and pass the $data variable to it. That function should return the class name for the given row :)


Viewing all articles
Browse latest Browse all 60

Trending Articles