2016-05-18 84 views
1

在視圖中,添加buttons會創建錯誤頁面。如何取出Update按鈕?從GridView刪除更新按鈕?

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 

回答

3

對不起,誰具有相同問題的其他用戶時使用錯誤:

的值:

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

改爲:

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

的伎倆。