0

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

Paritosh Mahale
  • 1,238
  • 2
  • 14
  • 42
  • Use bootstrap modal. [Read this](http://stackoverflow.com/questions/28470166/yii2-modal-dialog-on-gridview-view-and-update-button-shows-same-content-for-both). – Insane Skull Sep 28 '16 at 10:07

1 Answers1

2

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'));
           });
        });
    ");

?>
IStranger
  • 1,868
  • 15
  • 23
Mohan
  • 606
  • 4
  • 11