Grid Column Size in NULL results

When my grid view returns no results my ID column is suddenly much wider than when there are results in the grid.

This is probably due to the dynamic resizing of the columns based on the data returned.

How can I set the max width of the id column?

The following did not work for me…


    $columns = [

        [

            'attribute'=>'id',

            'contentOptions'=>['style'=>'width: 50px;']

        ],

    ];


    $columns = [

        [

            'attribute'=>'id',

            'contentOptions'=>['style'=>'max-width: 50px;']

        ],

    ];

Any suggestions ?

.

Hi,

try it like this:




'columns' => [

    [

        'class' => 'yii\grid\SerialColumn',

        'options' => [

            // any html options in "pair" => "value" format here

            'width' => '30px'

        ]

    ],

    [

        'attribute'=>'id',

        'options' => [

            'width' => '50px;'

        ]

    ],


]



Regards

Superb !!!

Thanks !!!

p.s. For future reference, in your second example there is a typo space extra : 'options ’

That threw an exception… remove the space and it works

Thanks for info.

Corrected the axample… ;)

Regards