3

I have following grid.

    $gridColumns = [
                'class'=>'kartik\grid\ActionColumn',
                'headerOptions'=>['class'=>'kartik-sheet-style'],
                'template' => '{delete}{my_button}', 
            ],

    echo GridView::widget([
            'dataProvider'=> $dataProvider,
            'columns' => $gridColumns,
            'filterModel' => $filterModel,
            ],
        ]);

I want add to template a new action button for example {my_button}.

arogachev
  • 33,150
  • 7
  • 114
  • 117
Jack
  • 329
  • 2
  • 5
  • 13

1 Answers1

8

You should simply add a buttons param to your column, e.g. :

'template' => '{my_button}', 
'buttons' => [
    'my_button' => function ($url, $model, $key) {
        return Html::a('My Action', ['my-action', 'id'=>$model->id]);
    },
]

Read more : http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html#$buttons-detail

soju
  • 25,111
  • 3
  • 68
  • 70