从GridView中删除更新按钮?

时间:2016-05-18 07:28:01

标签: php yii2 yii2-basic-app

在视图中,添加buttons会创建错误页面。

如何删除Update按钮?

enter image description here

以下是我的观点:

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

        'user.username',
        'title',
        'img_title',
        'note_type',

        ['class' => 'yii\grid\ActionColumn'],

        // I do not want the Update button.
        // Adding this 'button' creates a error.
        // 'buttons' => ['{view},{delete}']

    ],
]); ?>

添加“按钮”时的错误

Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: yii\grid\DataColumn::0

1 个答案:

答案 0 :(得分:3)

对不起,对于遇到同样问题的其他用户:

值:

['class' => 'yii\grid\ActionColumn'],

更改为:

[
    'class' => 'yii\grid\ActionColumn',
    'template' => '{view} {delete}'
],

做了这个伎俩。