Hide Yii2 GridView Action buttons

后端 未结 10 566
失恋的感觉
失恋的感觉 2021-02-03 21:20

I want to hide Yii2 GridView Action Column buttons on the base of model field status. If status is = 1 then hide view button only. How I can?

Code:

              


        
10条回答
  •  梦毁少年i
    2021-02-03 21:51

    Its works for me:

             'buttons' => [
                'view' => function ($url, $model) {
                    return $model->status == '' ? Html::a('', $url, [
                                'title' => Yii::t('app', 'Visualizar'),
                                //'class'=>'btn btn-primary btn-xs',                                  
                    ]) : '';
                },
    

    is the same as: return $model->status == '' ? 'show_action_here' : 'no_show';

提交回复
热议问题