2017-01-17 10:13:17 0 评论 Yii 2.0 Boy.Lee

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