yii2在gridview中更改控制器操作 [英] yii2 change controller action in gridview

查看:107
本文介绍了yii2在gridview中更改控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ItemController,并在actionView中放置了Itempicture的gridview,并且想要在单击图标视图时进行更新和删除,然后转到ItempictureController.

I have ItemController and in actionView I put gridview of my Itempicture, and I want when I click on icon view, update and delete then go to ItempictureController.

那么如何在具有不同控制器的gridview中更改控制器动作?

so How to change controller action in gridview with different controller?

推荐答案

在您的网格视图中,添加

In your gridview,add like

[
  'class' => 'yii\grid\ActionColumn',
  'template' => '{new_action1}{new_action2}',
  'buttons' => [
    'new_action1' => function ($url, $model) {
        return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', 'controller/action?id='.$model->id, [
                    'title' => Yii::t('app', 'New Action1'),
        ]);
    }
  ],
],

希望这会起作用!

这篇关于yii2在gridview中更改控制器操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆