CGridView and colspan


This is my first post and I’m sorry for my English

I have a problem when I use ‘htmlOptions’ => array(‘colspan’ => 2). <td> tags are Ok, but <th> are break( 7 <th> tags and 6 <td> tags)

Any help?

Can you post your CGridView code and the resulting html output? It would help us to better narrow down the problem.

<?php $this->widget('zii.widgets.grid.CGridView', array(


    'cssFile' => Yii::app()->baseUrl . '/css/admin/gridview/styles.css',

















            'htmlOptions'=>array('style'=>'width:32px;', 'colspan'=>'0'),



                'up' => array



                    'imageUrl'=>Yii::app()->request->baseUrl . '/css/admin/gridview/up.png',


                    'visible'=>'$data->position > 1',

                    'click'=>'function(){alert("Going up!");}',


                'down' => array



                    'imageUrl'=>Yii::app()->request->baseUrl . '/css/admin/gridview/down.png',


                    'visible'=>'$data->position <'. $model->totalCount,

                    'click'=>'function(){alert("Going down!");}',










)); ?>

Make sure you insert all code between code tags. You can do that with the "Insert code snippet" button that has the "<>" graphic on it. This will make your code easier to read for others.


Thanks for that advice.

Any ideas for my problem?

Problem is that the CGridView code renders the exact number of header… it does not know that you don’t want one of the headers…

So the only solution here is to hide the header that you don’t need…

So in the buttonColumn with the {up} and {down} just add this line


it will hide the header from that column, as you set the previous header to span to this column…

and you can remove the ‘colspan’=>0

I would avoid using "colspan=0" in the buttons column. According to W3C it is not supported in any of the major browsers and it only works when a "colgroup" is defined. Also, you only want the header to span across the remaining columns, not the buttons. Try removing the "colspan=0" under the buttons.

mdomba’s solution should work as well.

If you really need this, you can build your custom CGridColumn. See here (adapt the example to renderHeaderCell()):

I used ‘headerHtmlOptions’=>array(‘style’=>‘display:none’) and all is OK


Hi, i’m new on Yii and i need help… i have this view on my admin. and i need to pot up of name(nombre) and lastname(apellido) something like Director…

any idea?