i'm a new yii2 developer ! i made a GridView and the code is shown below :
<?php Pjax::begin(); ?> <?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\ActionColumn'],
['class' => 'yii\grid\CheckboxColumn'],
['class' => 'yii\grid\SerialColumn'],
'id',
'countryCode',
'countryName',
'currencyCode',
],
]); ?>
<?php Pjax::end(); ?>
a screenshot of output : OUTPUT
now i want to have a column contain some button and that button for example open a page or somthing else ! my problem is how can i create that column ?
You can also add the button (or as many as you like) to the existing action column like this
<?= GridView::widget([
::
::
'columns' => [
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete} {myButton}', // the default buttons + your custom button
'buttons' => [
'myButton' => function($url, $model, $key) { // render your custom button
return Html::a(..);
}
]
]
::
::
'currencyCode'
]
]); ?>
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