Yii2 的 GridView 中自定义默认操作按钮

// ['class' => 'yii\grid\ActionColumn'],
[
'class' => 'yii\grid\ActionColumn',
'header'=>'操作',
'headerOptions'=>['width'=>'130'],
'template' => '

{recharge} {view} {delete}
',
'buttons'=>[
'recharge'=>function($url,$model){
return '充值';
},
'view'=>function($url,$model){
return '查看';
},
'delete'=>function($url,$model){
return '删除';
},
[
'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
],
],
],

你可能感兴趣的:(Yii2 的 GridView 中自定义默认操作按钮)