CGridView and colspan

Hi,

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(

	'id'=>'users-grid',

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

	'dataProvider'=>$model->search(),

	'columns'=>array(

		'id',

        'username',

        'email',

        'register_date',

        array(

            'name'=>'position',

            'header'=>Yii::t('yii','Position'),

            'value'=>'$data->position',

            'type'=>'raw',

            'headerHtmlOptions'=>array('colspan'=>'2'),

        ),

		array(

			'class'=>'CButtonColumn',

            'template'=>'{up}{down}',

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

            'buttons'=>array

            (

                'up' => array

                (

                    'label'=>'up',

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

                    'url'=>'"#"',

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

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

                ),

                'down' => array

                (

                    'label'=>'down',

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

                    'url'=>'"#"',

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

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

                ),

            ),

		),

		array(

			'class'=>'CButtonColumn',

            'template'=>'{view}{update}{delete}',

            'headerHtmlOptions'=>array('style'=>'width:60px;'),

		)

	),

)); ?>



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.

Excellent!

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


 'headerHtmlOptions'=>array('style'=>'display:none'),

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()):

http://www.yiiframework.com/forum/index.php?/topic/15963-cgridview-footer-like-header/page__view__findpost__p__79334

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

Thanks

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…

http://www.subirimagenes.com/imagen-pantallazo-8939416.html

any idea?