Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set width of gridview in yii2

Tags:

php

yii2

how can I set width of column of gridview in view yii2, reference link as below,

like image 838
Piyush Sapariya Avatar asked Oct 30 '17 11:10

Piyush Sapariya


2 Answers

try this,

<?=
    GridView::widget([
        'model' => $model,
        'options' => ['style' => 'width:80%'],
        'attributes' => [
            'id',
        ],
    ])
?>
like image 170
krupal parsana Avatar answered Sep 16 '22 19:09

krupal parsana


To set width of one column individually something like the following:

[
    'attribute' => 'attribute_name',
    'headerOptions' => ['style' => 'width:20%'],
],

For all columns try:

[ 
    'class' => 'yii\grid\SerialColumn', 
    'contentOptions' => ['style' => 'width:100px;'], 
],
like image 33
Kyle Avatar answered Sep 16 '22 19:09

Kyle