Afif Sungkawa Afif Sungkawa - 5 months ago 8
PHP Question

i want to change the destination of my ActionColumn's button view to the different table in same database

i want to change the destination of my ActionColumn's button view to the different table in same database...

<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],

// 'id',
'nama_siswa',
'bahasa_indonesia',
'bahasa_inggris',
'matematika',
'kejuruan',

['class' => 'yii\grid\ActionColumn'],
],

]); ?>

Answer

You can Change view button url as:- which points to another action controller or url

Change ActionColumn Decorator as : -

<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
    ['class' => 'yii\grid\SerialColumn'],

   // 'id',
    'nama_siswa',
    'bahasa_indonesia',
    'bahasa_inggris',
    'matematika',
    'kejuruan',
    [
       'class' => 'yii\grid\ActionColumn',
       'buttons' => [
           'view' => function(){
                    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['/other-controller/action'], []);
                }
            ]
        ],
    ],

]); ?>