我一直在試圖在互聯網上找到答案,但我可以找到任何東西。我在網絡開發方面頗爲新穎,所以對我來說這是個問題。如何文本換行 - DataGridView Yii2框架
問題: 當我爲任何值設置最大寬度時,文本變爲beyound單元格。我需要找到一種方法來包裝它。有沒有可能通過小部件屬性做到這一點?感謝您的回答
<?php
echo GridView::widget([
'dataProvider' => $provider,
'options' => ['style' => 'max-height:30px;',
'max-width:10px;',
],
'columns' => [
['class' => 'yii\grid\SerialColumn',
'contentOptions'=>['style'=>'width: 30px;']],
//subject
[
'attribute' => 'subject',
'format' => 'text',
'label' => 'Subject',
'contentOptions'=>[
'style'=>
['width: 10px;',],
]
],
//body
[
'attribute' => 'body',
'format' => 'text',
'label' => 'Body',
'contentOptions'=>['style'=> 'max-width: 100px;', 'height: 100px']
],
['class' => 'yii\grid\ActionColumn',
'controller'=>null,
'header'=>'Action',
'headerOptions' => ['width' => '70'],
],
],
'tableOptions' =>['class' => 'table table-striped table-bordered'],
]);
?>
我看不到圖片。請提供或解釋更好。 Probabily你無法上傳圖片。在這種情況下提供示例 – scaisEdge
@scaisEdge well http://screenshot.sh/oAFzkKXyDOrPB –
爲什麼代碼中的最大高度或樣式高度?如果你使用這個設置文本換行是沒有用的。 – scaisEdge