Yii2 的 GridView 中自定义默认操作按钮
// ['class' => 'yii\grid\ActionColumn'],
[
'class' => 'yii\grid\ActionColumn',
'header'=>'操作',
'headerOptions'=>['width'=>'130'],
'template' => '<div class="btn-group" role="group">{recharge} {view} {delete} </div>',
'buttons'=>[
'recharge'=>function($url,$model){
return '<a class="btn btn-default btn-xs btn-warning" href="'.$url.'" role="button">充值</a>';
},
'view'=>function($url,$model){
return '<a class="btn btn-default btn-xs btn-info" href="'.$url.'">查看</a>';
},
'delete'=>function($url,$model){
return '<a class="btn btn-default btn-xs btn-danger" data-method="POST" href="'.$url.'">删除</a>';
},
[
'url' => 'delete',
'class' => 'btn btn-xs btn-danger',
'label' => Yii::t('yii', 'Delete'),
'options' => [
'data-action' => 'delete',
],
'appendReturnUrl' => true,//是否保留当前URL,默认为true
'url_append' => '',
'keyParam' => 'id', //是否传id,不传设置null
],
],
],