代码之家  ›  专栏  ›  技术社区  ›  Beginner m latha

如何使Yii2 GridView响应?

  •  3
  • Beginner m latha  · 技术社区  · 7 年前

    我在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在mobile中没有响应。如何使GridView页面响应?

    2 回复  |  直到 7 年前
        1
  •  8
  •   Bizley    7 年前

    如中所述 Bootstrap documentation :

    通过包装任何 .table 在里面 .table-responsive

    所以只要把你的小部件包起来

    <div class="table-responsive">
    // GridView here
    </div>
    
        2
  •  3
  •   Forest    6 年前

    这是 正当 选项

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