如何使 Yii2 GridView 响应?

How to make a Yii2 GridView responsive?

我在 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 页面响应?

Bootstrap documentation 中所述:

Create responsive tables by wrapping any .table in .table-responsive

所以只需将小部件包装在

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

这里是正确的选项。

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