Skip to main content

Posts

Showing posts with the label rowCssClassExpression

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

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 :)