【发布时间】:2014-03-11 05:58:25
【问题描述】:
yii 中是否有任何方法可以创建多个行标题并将其与 GridView 中的其他列合并。像这样的东西:http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html.
我只看到 GroupGridView 的值不在标题上。谢谢。
【问题讨论】:
yii 中是否有任何方法可以创建多个行标题并将其与 GridView 中的其他列合并。像这样的东西:http://www.dotnettwitter.com/2010/12/how-to-create-multiple-row-header-and.html.
我只看到 GroupGridView 的值不在标题上。谢谢。
【问题讨论】:
【讨论】:
没有使用网格视图执行此操作的默认方法。您可以使用 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
它支持许多复杂的网格结构
【讨论】: