Reputation: 1316
I want to design an custome popup ( not like delete) in gridview with jquery button click event button is in action column ob gridview
how can add popup with id of each row
Upvotes: 0
Views: 1272
Reputation: 616
Try this, Insert
use yii\helpers\Url;
use yii\bootstrap\Modal;
Into u'r index.php
[
'class' => 'yii\grid\ActionColumn',
'header' => 'Action',
'template' => '{view} {update} {delete} {your_link}',
'buttons' => [
'your_link' => function ($url, $model) {
$url = Url::to(['controller / action', 'id' => $model->id]);
return Html::a(' <span class="glyphicon glyphicon-eye-open" title = "Tooltip Name" ></span> ', 'javascript:void(0)', ['class' => 'anyClassName', 'value' => $url]);
},
],
],
Define modal and Register this JS into you'r index file
<?php
Modal::begin([
'id' => "modal",
'header' => '<h3>Assign Farmers to other Farm Mitra</h3>',
]);
echo "<div id='modalContent'></div>";
Modal::end();
$this->registerJs(
"$(document).on('ready pjax:success', function() {
$('.list').click(function(e){
e.preventDefault(); //for prevent default behavior of <a> tag.
$('#modal').modal('show').find('#modalContent').load($(this).attr('value'));
});
});
");
?>
Upvotes: 2