php - 向 Yii2 CRUD GridView 添加一个类

标签 php gridview yii2

我一直在尝试向 Yii2 的 CRUD GridView 中的图像列添加一个类。到目前为止,我已经成功地显示了图像,但是显示了它的全宽和全高。我需要向图像添加“col-md-3”bs 类。

这是我完成的:

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        'emp_firstname',
        'emp_lastname',
        'emp_photo' => [
            'format' => 'image',
            'attribute' => 'emp_photo',
            'value' => 'emp_photo',
            'contentOptions' => ['class' => 'col-md-3'],
        ],

        ['class' => 'yii\grid\ActionColumn'],
    ],
]); ?>

最佳答案

如果你想向表中添加 id 或 class 或两者 试试这个。

'tableOptions' => [
        'id' => 'theDatatable',
        'class'=>'table table-striped table-bordered'
        ],

关于php - 向 Yii2 CRUD GridView 添加一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39416620/

相关文章:

Yii2:注销用户时不允许使用方法(#405)

twitter-bootstrap-3 - Yii2 中的多级引导菜单

php - 将 MYSQL 查询转换为 Laravel 方式

php - sql更新不改变数据库中的数据

php - Zend 框架关系与表选择

c# - SqlDataSource GridView 的总行数

module - Yii2 自定义/较短的命名空间

php - 如何在 Ubuntu 16.04 中安装 php-curl

qt - QML GridView 隐藏一个单元格

javascript - 使用 JavaScript 查找发件人