Reputation: 311
I need to specify width for the certain column ('file_name' for example). I have tried these suggestions but it doesn't work for me.
One of the possible solutions is to make columns resizable but I don't know how to do it either.
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'tableOptions'=>['class'=>'table-striped table-bordered table-condensed'],
'options'=>['style' => 'white-space:nowrap;'],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'lastname',
'firstname',
'middlename',
'rs_account',
'sum',
'file_name',
'state',
'history_id',
[
'label' => 'Code',
'attribute' => 'codes.code',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Upvotes: 4
Views: 10400
Reputation: 2654
use headerOptions:
[
'attribute' => 'attribute_name',
'headerOptions' => ['style' => 'width:20%'],
],
Upvotes: 0
Reputation: 133400
You should use contentOptions for the every single attribute you want to style
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'tableOptions'=>['class'=>'table-striped table-bordered table-condensed'],
'options'=>['style' => 'white-space:nowrap;'],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'lastname',
'firstname',
'middlename',
'rs_account',
'sum',
['attribute' => 'file_name',
'label' =>'Filename'
'contentOptions' => ['style' => 'width:680px; min-width:600px; '],
],
'state',
'history_id',
[
'label' => 'Code',
'attribute' => 'codes.code',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Upvotes: 7