sanat
(Lbravof)
1
Hi Community,
I’m trying to add a css style to a column in a CGridView, but it doesn’t work, here is part of the code:
In admin.php (view folder):
…
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'juridicas-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array( 'name' =>'id_juridica', 'value' => '$data->id_juridica', 'header' => 'No Empresa', 'htmlOptions' => array('class'=>'red')),
...others columns
array( 'class'=>'CButtonColumn', 'template' => '{view}'),
),
)); ?>
Only I want to display the column ‘id_juridica’ in red color, so I’d created a class red in my main.css file, here is the code:
main.css
.red
{
color:red;
}
and I’m using ‘htmlOptions’ => array(‘class’=>‘red’) to apply the class in the colummn.
What I’m doing wrong ?, any help will be apreciated, thanks in advance.
Edofre
(Edofre)
2
Are you using your own css file or the main.css that came with your yii application?
I just recreated it the way you have and it worked without problems for me,
My GridView
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'activity-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'columns' => array(
'id',
array(
'name' => 'name',
'value' => '$data->name',
'htmlOptions' => array('class' => 'red'),
),
array(
'class' => 'CButtonColumn',
),
),
));
?>
and my main.css (The one that came with the Yii application)
.red
{
color:red;
background-color:black;
}
sanat
(Lbravof)
3
Thanks Edofre, the problem was in the browser’s cache. I clean it and it works.
Thanks Community