in view file, add the following to CButtonClass section of the array:
<?php $this->widget('zii.widgets.grid.CGridView', array(
.....
'columns' => array(
....
array(
'class' => 'CButtonColumn',
'buttons' => array(
'view' => array(
'url' => 'url' => 'Yii::app()->createUrl("/path/to/controller/view")',
'options' => array(
'ajax' => array(
'type' => 'POST',
'url' => "js:$(this).attr('href')",
'update' => '#detail-section',
),
),
), // view button
),
),
)
)) ?>
<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'dlg-detail',
'options' => array(
'title' => 'Dialog Box Title',
'closeOnEscape' => true,
'autoOpen' => false,
'model' => false,
'width' => 550,
'height' => 450,
),
)) ?>
<div id="detail-section"></div>
<?php $this->endWidget() ?>
change the view action in controller file:
public function actionView($id) {
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('_view', array(
'model' => $this->loadModel($id),
), false, true);
Yii::app()->end();
}
}
Thanks for sharing your experience, it was very useful.
ReplyDeleteToto Roncone.