Styling Column In Cgridview

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'=&gt;'juridicas-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,


'columns'=&gt;array(


	array( 'name' =&gt;'id_juridica', 'value' =&gt; '&#036;data-&gt;id_juridica', 'header' =&gt; 'No Empresa', 'htmlOptions' =&gt; array('class'=&gt;'red')),


	...others columns


	array( 'class'=&gt;'CButtonColumn', 'template' =&gt; '{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.

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;

}

Thanks Edofre, the problem was in the browser’s cache. I clean it and it works.

Thanks Community