CGridView rowspan

Hi everyone,

I have read all forum topics related to my question, but i did not find any solution.

I am working with CGridView and should use rowspan and colspan tag together.

The attached cgridview_1.png is the normal CGridView layout, but I’d like to rowspan the cell with the checkbox, and then colspan the new ones (like in cgridview_2.png).

My code now is something like this:




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

		'dataProvider'=>$dataProvider,

		'columns'=>array(

			array(

				'name'=>'',				

'value'=>'CHtml::checkBox("rows[]",null,array("value"=>$data->id,"id"=>"ccc_".$data->id))',

				'type'=>'raw',

				'htmlOptions'=>array('width'=>5),

			),

			

			array(

				'name' => 'id',

				'header'=>'ID',

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

				'sortable' => true,

				'htmlOptions'=>array('style'=>'text-align: center'),

			),

			array(

				'name' => 'col',

				'header'=>'Column',

				'value' => 'test',

			),

			),

		'selectableRows'=>'1',

		'enableSorting'=>true,

	));



The desired HTML code is (for a row, like in cgridview_2.png):




<tr class="odd">

	<td width="5" rowspan="2"><input type="checkbox" name="rows[]" id="ccc_1" value="1"></td>

	<td style="text-align: center">1</td>

	<td>test</td>

</tr>

<tr class="odd"><td colspan="2">aaaa</td></tr>



but I don’t know how to do it with CGridView. Could anyone suggest something?

Thank you very much,

MArkus

I’d rather use CListView in your case.

AFAIK, if you want to do it with a grid view, you have to write your own grid view class extending CGridView. And it looks much easier using a CListView than writing a customized CGridView to suit your needs.

[EDIT]

See also this topic.http://www.yiiframework.com/forum/index.php?/topic/12968-subgrid/

raise this thread

if someone met the same problem and googling end up here, just try this solution link groupgridview

Thanks! =D