In view
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'type'=>'bordered',
'dataProvider'=>$model->search(),
'filter'=>$model,
'template'=>"{items}",
'columns'=>array(
'id',
'firstName',
'lastName',
'language',
'hours',
array(
'header'=>'Options',
'class'=>'bootstrap.widgets.TbButtonColumn',
'buttons'=>array(
'view'=>
array(
'url'=>'Yii::app()->createUrl("person/view", array("id"=>$data->id))',
'options'=>array(
'ajax'=>array(
'type'=>'POST',
'url'=>"js:$(this).attr('href')",
'success'=>'function(data) { $("#viewModal .modal-body p").html(data); $("#viewModal").modal(); }'
),
),
),
),
)
)));
?>
<!-- View Popup -->
<?php $this->beginWidget('bootstrap.widgets.TbModal', array('id'=>'viewModal')); ?>
<!-- Popup Header -->
<div class="modal-header">
<h4>View Employee Details</h4>
</div>
<!-- Popup Content -->
<div class="modal-body">
<p>Employee Details</p>
</div>
<!-- Popup Footer -->
<div class="modal-footer">
<!-- close button -->
<?php $this->widget('bootstrap.widgets.TbButton', array(
'label'=>'Close',
'url'=>'#',
'htmlOptions'=>array('data-dismiss'=>'modal'),
)); ?>
<!-- close button ends-->
</div>
<?php $this->endWidget(); ?>
<!-- View Popup ends -->
And in Controller
public function actionView($id)
{
if( Yii::app()->request->isAjaxRequest )
{
$this->renderPartial('view',array(
'model'=>$this->loadModel($id),
), false, true);
}
else
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}
}
Wow.. That works.. Thanks!
ReplyDeleteyou saved me!! :D
first grid is in which view?
ReplyDelete@ a rahim, I have used in admin view page and you can use where you need.
ReplyDeleteuse syntax highlighter for code
ReplyDeleteHi,
ReplyDeleteI have two more scenario unable to fix
1. If display one grid in main page & open second grid in model popup (Yii grid js load again so randomly any search / sort / pagination disturb)
2.i display grid inside multiple tabs using CJuiTabs ajax method. it also create same issue.
how can i use this code in yii2
ReplyDelete