//para cualquier campo usar: 'headerOptions' => ['style' => 'text-align:center;'], 'contentOptions' => ['style' => 'text-align:center; width:2%; vertical-align:middle;'], //para casos donde el campo venga del modelo $columns[] = [ 'attribute' => 'nombre_proyecto', 'label' => 'Nombre del Proyecto', 'headerOptions' => ['style' => 'text-align:center; width:10%;text-color:white;'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) { // Encoded to avoid XSS, then insert line breaks cada 40 caracteres $name = Html::encode($data->nombre_proyecto); return nl2br(wordwrap($name, 40, "\n", true)); }, 'format' => 'raw', ]; // para casos donde se use la funcion listar 'id_indicador' => [ 'attribute' => 'id_indicador', 'label' => 'Indicador', 'headerOptions' => ['style' => 'text-align:center;'], 'contentOptions' => ['style' => 'text-align:center; width:2%; vertical-align:middle;'], 'filter' => app\models\Indicadores::listAcuatico(), 'value' => function ($data) { $s = app\models\Indicadores::find()->where(['id_indicador' => $data->id_indicador])->one(); if (!$s) { return ''; } // Encoded to avoid XSS, then insert line breaks cada 20 caracteres $name = Html::encode($s->nombre_indicador); return nl2br(wordwrap($name, 40, "\n", true)); }, 'format' => 'raw', ],