【问题标题】:Yii create multiple row header and merge it with other columns in GridViewYii 创建多行标题并将其与 GridView 中的其他列合并
【发布时间】:2014-03-11 05:58:25
【问题描述】:

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

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

【问题讨论】:

    标签: php gridview yii


    【解决方案1】:

    我发现了这个http://omfarid.com/2012/06/extensi-yii-untuk-hierarki-header-cgridview/#disqus_thread。它实际上是在做我需要的。

    【讨论】:

    • 你为此做了什么?
    【解决方案2】:

    没有使用网格视图执行此操作的默认方法。您可以使用 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

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

    【讨论】:

    • 我已经看到了你所说的扩展,但它只适用于要合并的值(行/列)而不是标题。
    • 您可以将上面的列表视图用于上面所做的任何类型的标题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-21
    • 2017-12-30
    • 2023-04-09
    相关资源
    最近更新 更多