1

I have a database table with 32 columns and I successfully displayed them in the yii2 gridview. The problem is the 32 columns will not fit in the window. I want to add a horizontal scroll bar at the bottom. How can I do that?

Here is the screenshot.

enter image description here

userlond
  • 3,632
  • 2
  • 36
  • 53
beginner
  • 2,024
  • 5
  • 43
  • 76

4 Answers4

4

You just need to put a div around it and then set the overflow using CSS. You will need to set the height.

overflow: auto;
overflow-y: hidden;
Height:?
Ferdinand Balbin
  • 687
  • 1
  • 7
  • 13
1

If you are using Bootstrap 3 you can always use table-responsive class like so;

<div class="table-responsive">
    <?= GridView::widget(); ?>
</div>
Phemelo Khetho
  • 231
  • 1
  • 4
  • 14
0

i'm using kartik, just add :

'options' => ['style' => ['width' => '1800px']]

include resize font :

'options' => ['style' => ['font-size'=>'13px', 'width' => '1800px']],
Adityo
  • 111
  • 1
  • 3
0

You have to add div around GridView:

<div style="overflow-x: auto; width: 100%;">
     <?= GridView::widget...?>
</div>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
YurgenTM
  • 83
  • 1
  • 6