Yii2 GridView中实现断行断字
注意看代码中的 options 和 contentOptions
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'options' => [
'style'=>'overflow: auto; word-wrap: break-word;'
],
'columns' => [
['class' => 'yii\grid\SerialColumn'],
....
[
'attribute'=>'pi_desc',
'value'=>function ($model) { return $model->pi_desc; },
'format'=>'raw',
'label'=>'Desc',
'contentOptions' => ['style'=>'max-width:300px;'],
],
留言
SADi
2019-08-26 18:59:12Just use yii2 gridview column format: 'pi_desc:ntext'