how to add a column with a botton in kartrik gridview?

hi

i have a kartrik gridview like this:




  <?php

		

            echo GridView::widget([

			'dataProvider' => $dataProvider,

			//'filterModel' => $searchModel,

			//'exportConfig' => [

			//        GridView::CSV => ['label' => 'Save as CSV'],

			//         GridView::EXCEL => ['label' => 'Save as EXCEL']

			//    ],

			'columns' =>

			[

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

			     

			     [  'attribute' => 'val1'   ,'value'  => 'val1' ],

			     [  'attribute' => 'val2'   ,'value'  => 'val2' ],

			     [  'attribute' => 'val3'       ,'value'  => 'val3' ],

			     [  'attribute' => 'val4' ,'value'  => 'val4'  ],

			     

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

			

			],

			


]); ?>



i want add a column with a specific botton how can i do this?

pls help!

Easy:




['label'=>'mycolumn label', 'format' => 'raw', 'value'=>

	function ($model, $id) {

    	return Html::button('record id '.$id);

	}

],



Where $model is the corresponding row mode and $id is the record id.

In the function you can access all $model properties, if is an ActiveRecord you can access to related data as well (if a relation is defined in the model)