[
'attribute' => 'status',
'label' => '状态',
'value' => function ($model) {
return $model->status == 1 ? '开启' : '关闭';
},
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{close}',
'buttons' => [
// 自定义按钮
'close' =>
function ($url, $model, $key) {
$options = [
'title' => '显示',
'aria-label' => '显示',
'data-pjax' => '0',
];
return Html::a($model->status == 1 ? '关闭' : '开启', $url, $options);
},
]
],
close 就是当前控制器对应 方法名