I have a GridView of a index view with some columns. I added a print button that link to a URL that has to be opened in a new window.
This code work but the URL is not open in a new window.
'columns' => [
'column1',
'column2',
'column3',
'column4',
'column5',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{download} {update} {delete}',
'buttons' => [
'download' => function ($url, $model) {
return Html::a(
'<span class="fa fa-print"></span>',
'/disposicion-licencia/print-estival?id=' . $model->id,
[
'title' => 'Download',
'data-pjax' => '0',
]
);
},
],
],
]
I think I need JavaScript code like this:
window.open('/disposicion-licencia/print-estival?id=$id');
But I don't know where to use it.
For a new window you need 'target' => '_blank':
return Html::a(
'<span class="fa fa-print" ></span>',
'/disposicion-licencia/print-estival?id=' . $model->id,
[
'title' => 'Download',
'data-pjax' => '0',
'target' => '_blank',
]
);