Yii create multiple row header and merge it with o

2020-07-23 03:46发布

Is there any way in yii to create multiple row header and merge it with other columns in GridView. Something like this:http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html.

I am only seeing GroupGridView for the values not on the headers. Thanks.

标签: php gridview yii
2条回答
Explosion°爆炸
2楼-- · 2020-07-23 04:18

There is no default way to do this using grid view. You can either you use ListView and modify the header template very easily.. in the view passed to the ListView widget you can simply use

//Widget Call in your initial view

$this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_myview',   // refers to the partial view named '_myviwq'
));

...

//Partial View File _myview

<?php ($index === 0){ ?>
    // Called before first item
    // Your Header template goes here ; 
    // In your case thead with th having colspan > 1 as required
    // If have open tags here that are unclosed(like <table>) 
    // then you will also need to use another if condition at the end as show below
<?php } ?>

   // The normal view template typically a <tr></tr>

<?php if($widget->dataProvider->totalItemCount == ($index+1)){ ?>
    // Called after the last item only
// Close all opened tags here like </table>
 <?php }?>

Alternatively if you wish to use GridView only you can try a third party extension like http://yiiwheels.2amigos.us/site/grid#groupgridview

It has support for many complex grid structures

查看更多
登录 后发表回答