Yii Framework Forum: Yii2, change column width - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Yii2, change column width How to change column width?

#1 User is offline   gintare 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 19-July 14

Posted 23 August 2015 - 02:21 AM

How to change the column width?

I have found several examples how to chnage the column width, but none of them work for me:
http://www.stackover...et-column-width
http://www.bsourceco...ridview-options
http://stackoverflow...umn-size-in-yii

I tried several ways, but none is working:
// TO SET FIXED WIDTH TO ALL COLUMNS
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
            'class' => 'yii\grid\SerialColumn',
            'contentOptions'=>[ 'style'=>'width: 400px'], 
            ],
          'th',
          'growth_mech',
          'growth_meth',
           'ns', 
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

//There are no style definitions generated in the source
<table class="table table-striped table-bordered"><thead>

// TO SET FIXED WIDTH TO SINGLE COLUMN
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
            'class' => 'yii\grid\SerialColumn',
            ],
          [
             'attribute'=>'th',
             'value'=>'th',
             'contentOptions'=>['style'=>'width: 520px;']
          ],
          'growth_mech',
          'growth_meth',
           'ns', 
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
// There is no style definition generated in the source
<th><a href="/thyii/basic/web/index.php?r=alldata2%2Findex&amp;sort=th" data-sort="th">Th</a></th>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users