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.
so How to change controller action in gridview with different controller?
You need to set $controller property of yii\grid\ActionColumn. In your case, try this:
[
'class' => 'yii\grid\ActionColumn',
'controller' => 'itempicture'
]
http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html#$controller-detail
If you are using yii\data\ArrayDataProvider, make sure you set $key property like:
$dataProvider->key = 'id'; //id is the primary key name of your Itempicture model.
http://www.yiiframework.com/doc-2.0/yii-data-arraydataprovider.html#$key-detail
Hope it helps.
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'),
]);
}
],
],
Hope this will work!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With