Pawan Pawan - 2 years ago 88
PHP Question

Prevent GridView ActionColumn icons from wrapping globally

I tried to find the answer, but couldn't and wonder why it is designed like this:

My action columns icons do wrap one below the other.

I have to add this line of code in every

to show icons on one line:

'class' => 'yii\grid\ActionColumn',
'contentOptions' => ['width' => '80px;'],

Is there any better method to show the action icon on one line globally?

Answer Source

You should create file "container.php" in config folder. And put this code

\Yii::$container->set('yii\grid\ActionColumn', [
        'contentOptions' => ['width' => '80px;'],

Then, You should include this file in your "web/index.php". Like that


// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/../config/web.php');

require(__DIR__ . '/../config/container.php');

(new yii\web\Application($config))->run();

It is work like that -

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download