I have Users model.
Displaying it with CGridView i want to color the rows depending on $model->is_admin
which is an integer either 0 or 1, so either of 2 colors.
Could it be done by simple settings of CGridView ?
Controller
/**
* Lists all models.
*/
public function actionIndex() {
$model = new Users('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Users']))
$model->attributes = $_GET['Users'];
$this->render('index', array(
'model' => $model,
));
}
View
<div class="row">
<div class="col-sm-12 table-responsive">
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'users-grid',
'itemsCssClass' => 'table table-bordered table-hover dataTable',
'dataProvider' => $model->search(),
'enablePagination' => false,
// 'filter'=>$model,
'columns' => array(
'username',
'first_name',
'last_name',
'email',
),
array(
'class' => 'CButtonColumn',
),
),
));
?>
</div>
</div>