Is it possible to style CGridView based on data? For example these two cases:
Or I have to use other options?
Yes, you can specify css
class by data. Use cssClassExpression option.
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
// ...
array(
'name'=>'Delta',
'value' => $data->value,
'cssClassExpression' => '$data->delta > 0 ? "up" : "down"',
),
// ...
),
));