Piyush Sapariya
Piyush Sapariya

Reputation: 538

how to set width of gridview in yii2

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

Upvotes: 7

Views: 6337

Answers (2)

Kyle
Kyle

Reputation: 735

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;'], 
],

Upvotes: 3

krupal parsana
krupal parsana

Reputation: 132

try this,

<?=
    GridView::widget([
        'model' => $model,
        'options' => ['style' => 'width:80%'],
        'attributes' => [
            'id',
        ],
    ])
?>

Upvotes: 6

Related Questions