Yii创建多个行标题并将其与GridView中的其他列合并

时间:2014-03-11 05:58:25

标签: php gridview yii

在yii中是否有任何方法可以创建多个行标题并将其与GridView中的其他列合并。这样的事情:http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html

我只看到GroupGridView的值不在标题上。感谢。

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

使用网格视图没有默认方法。您可以使用ListView并非常轻松地修改标题模板..在传递给ListView小部件的视图中,您只需使用

//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 }?>

或者,如果您只想使用GridView,可以尝试使用第三方扩展程序 http://yiiwheels.2amigos.us/site/grid#groupgridview

它支持许多复杂的网格结构