Hi all,
I’m trying to open modal for viewing/editing single row data from a gridview, using yiiStrap (I think with bootstrap is the same).
This is the view:
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'scadenza-grid',
'dataProvider' => $model->search(),
'filter' => NULL,
'columns' => array(
...
array(
'class' => 'CButtonColumn',
'template' => '{view} {update}',
'buttons' => array(
'view' => array(
'click' => 'js:function(id)
{
var x = document.getElementById("codice");
x.value = $.fn.yiiGridView.getSelection("scadenza-grid");
}',
'options' => array(
'data-toggle' => 'modal',
'data-target' => '#finestra',
),
),
),
),
...
));
$this->widget('bootstrap.widgets.TbModal', array(
'id' => 'finestra',
'header' => 'Dettaglio scadenza',
'remote' => Yii::app()->createUrl('scadenza/viewmod'),
'footer' => array(
TbHtml::button('chiudi', array('data-dismiss' => 'modal')),
),
));
And this is the controller:
public function actionViewmod() {
$selpk = Yii::app()->request->getQuery('id');
$this->renderPartial('viewmod', array(
'model' => $this->loadModel($selpk),
));
}
The problem is that I need the grid id in the controller and cannot send it from the view as a parameter. I cannot parameterize the modal definition, because it’s created before of the user interaction; and the “url” option of the button is ignored.
Neither the "getQuery" in the first row of the action runs.
I tried to capture it in the "click" option of the button (as shown) and put it in an hidden field to be read later, with no success (may be this is for my lack in js/ajax).
Help me! Thx