gridview - Modal pop up in grid view in yii2 -


i pop modal when click on button inside grid view. possible yii2 gridview?

<?= gridview::widget([         'dataprovider' => $dataprovider,         'filtermodel' => $searchmodel,         'columns' => [             ['class' => 'yii\grid\serialcolumn'],               'time_zone',             'no_of_users',             'bill_name',             'bill_address',             'names.name',             'bill_state',             'bill_city',             'bill_postal',             'bill_mobile',              ['header'=>'plan info',             'value'=> function($data)                     {                          //~ print_r($data);die();                         return  html::a(yii::t('app', ' {modelclass}', [                             'modelclass' => 'details',                         ]), ['userdetails/plans','id'=>$data->id], ['class' => 'btn btn-success    ']                          );                           },             'format' => 'raw'             ],                ['class' => 'yii\grid\actioncolumn'],         ],     ]); ?> 

in above grid view want modal popup when click on button 'details'.

thanks,

yes, possible. achieve follow below steps.

add modal code above gridview code.

<?php     yii\bootstrap\modal::begin(['id' =>'modal']);     yii\bootstrap\modal::end(); ?> 

after add id in details button. as,

[     'header'=>'plan info',     'value'=> function($data)               {                     return  html::a(yii::t('app', ' {modelclass}', [                           'modelclass' => 'details',                           ]), ['userdetails/plans','id'=>$data->id], ['class' => 'btn btn-success', 'id' => 'popupmodal']);                     },      'format' => 'raw' ], 

and register javascript @ top or bottom of view page.

$this->registerjs("$(function() {    $('#popupmodal').click(function(e) {      e.preventdefault();      $('#modal').modal('show').find('.modal-content')      .load($(this).attr('href'));    }); });"); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -