答案 0 :(得分:6)
您应该对要设置样式的每个属性使用contentOptions
<?= 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'],
],
]); ?>
答案 1 :(得分:0)
使用headerOptions:
[
'attribute' => 'attribute_name',
'headerOptions' => ['style' => 'width:20%'],
],