如何使Yii2 GridView响应?

时间:2018-03-10 09:37:14

标签: gridview responsive-design yii2 yii2-advanced-app

我在Yii2中有一个常见的GridView。

<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'tableOptions' => ['class' => 'table table-striped table-bordered table-responsive'],
        'columns' => [
              'firstName',
              'lastName',   
              [
                 'attribute' => 'verified',
                 'format' => 'html',
                 'value' => function($data){  
                      ....
                  }
              ],
         ]
]); ?>

GridView在移动设备中没有响应。如何使GridView页面响应?

2 个答案:

答案 0 :(得分:3)

正如Bootstrap documentation中所述:

  

通过在.table

中包装任何.table-responsive来创建自适应表格

所以只需将您的小部件包装在

<div class="table-responsive">
// GridView here
</div>

答案 1 :(得分:2)

这是右键选项。

<?= GridView::widget([
'tableOptions' => [
    'class' => 'table table-striped',
],
'options' => [
    'class' => 'table-responsive',
],
'dataProvider' => $dataProvider,