Open popup modal from CGridView


(Nurillyana Ahmad) #1

Hello…

I have using CGridView and there are buttons in the table. Currently I am using default popup alert but I want to open a Modal when user click on the Delete button. How can I make it?

This is my code for CGridView:




<?php

                        $this->widget('zii.widgets.grid.CGridView', array(

                            'id' => 'mobile-comment-grid',

                            'dataProvider' => $model->search(),

                            'itemsCssClass' => 'table table-striped table-bordered table-hover',

                            'pagerCssClass' => 'dataTables_paginate',

                            'pager' => array('class' => 'PagerSA', 'header' => ''),

                            'summaryText' => '',

                            'emptyText' => 'Tiada data dijumpai',

                            'columns' => array(

                                array('header' => 'No', 'value' => '($this->grid->dataProvider->pagination->offset+$row+1)', 'htmlOptions' => array('width' => '1', 'align' => 'center')),

                                array('type' => 'raw', 'name' => 'share_id', 'value' => '"<a href=\'index.php?r=MobileShare/view2&id=".$data->share_id."\' target=\'_blank\'>".$data->share_id."</a>"'),

                                array('name' => 'user_id', 'value' => '$data->displayUser()', 'htmlOptions' => array('width' => '250', 'align' => 'center')),

                                array('name' => 'comment', 'value' => '$data->comment'),

                                array('name' => 'created_dt', 'value' => '$data->created_dt'),

                                array('header' => 'Tindakan', 'class' => 'CButtonColumn',

                                    'deleteConfirmation' => "js:'Are you sure to delete this data?'",

                                    'template' => '{view}&nbsp;&nbsp;{delete}&nbsp;&nbsp;{approve}',

                                    'htmlOptions' => array('width' => '170', 'align' => 'left'),

                                    'buttons' =>

                                    array(

                                        'view' => array(

                                            'options' => array('rel' => 'tooltip', 'data-toggle' => 'tooltip', 'title' => 'Butiran', 'class' => 'btn btn-xs btn-purple'),

                                            'label' => '&nbsp;<i class="ace-icon fa fa-info bigger-120"></i>&nbsp;',

                                            'url' => 'Yii::app()->createUrl("MobileComment/view2&id=".$data->id)',

                                            'imageUrl' => false,

                                        //'visible' => '0'

                                        ),

                                        'approve' => array(

                                            'options' => array('rel' => 'tooltip', 'data-toggle' => 'tooltip', 'title' => 'Approve', 'class' => 'btn btn-xs btn-success'),

                                            'label' => '<i class="ace-icon fa fa-check bigger-120"></i>',

                                            'url' => 'Yii::app()->createUrl("MobileComment/update2&id=".$data->id."&status=approve")',

                                            'imageUrl' => false,

                                            'visible' => '$data->status=="pending"'

                                        ),

                                        'delete' => array(

                                            'options' => array('rel' => 'tooltip', 'data-toggle' => 'tooltip', 'title' => 'Hapus', 'class' => 'btn btn-xs btn-warning'),

                                            'label' => '<i class="ace-icon fa fa-trash-o bigger-120"></i>',

                                            'url' => 'Yii::app()->createUrl("MobileComment/delete&id=".$data->id)',

                                            'imageUrl' => false,

                                            'click' => 'function(){}'

                                        ),

                                    ),

                                ),

                            ),

                        ));

                        ?>



Hope someone can help me. Thank you