CGridView selectionChanged

Hi there,

I’m fairly new to Yii and have just run into a little problem which I cannot figure out…

I’ve followed this article

CGridView: Display the full record (actionView) in a CJuiDialog

and it’s working nicely in my application.

Though now I would like the same dialog to come up when I just click on a row in the CGridView. I imagine using ‘selectionChanged’ for that would be the right thing to do but I’m not that good at Ajax or JQuery and am not sure how the function would have to look like for that…

Could anyone please shed some light?

Many thanks!

Nobody has any ideas? :unsure:

Maybe I’ll give a few more details about what I’m trying to do…

In the mentioned article this code used in the Button column basically calls the actionView as a dialog:


'buttons'=>array('view'=>

array(

    'url'=>'Yii::app()->createUrl("address/view", array("id"=>$data->ID,"asDialog"=>1))',

    'options'=>array(  

    'ajax'=>array(

            'type'=>'POST',

                // ajax post will use 'url' specified above 

            'url'=>"js:$(this).attr('href')", 

            'update'=>'#id_view',

           ),

     ),

     ),

   ),

The actionView more or less looks like this:


public function actionView($id)

{

 if (Yii::app()->request->isAjaxRequest) 

  {

    $this->renderPartial('view', array(

                                   'model'=>$this->loadModel($id),

                                   'asDialog'=>!empty($_GET['asDialog']),

                                 ),

                          false,true);

     Yii::app()->end();

   }

 else

    $this->render('view', array(

       'model'=>$this->loadModel($id),

     ));

}

And the view contains a CJuiDialog which is then opened.

Now that works great in my CGridView but in addition to the button opening the dialog I would also like a click anywhere on a row to show the same dialog.

I’m sure it’s possible with ‘selectionChanged’ but what code do I need to put there!?

Again thanks a lot for any help!

I know it’s been a while but did you actually got this working?

I need the same. Basically clicking a row of a CGridView, this will trigger the method "selectionChanged" where I do a "jQuery.ajax(…" which triggers an action in my controller, this action does a "renderPartial" of a php file that contains a dialog.

Inside the success method of the jQuery.ajax I attempt the following but it doesn’t work:




$("#detailsDialog").dialog("open");

Diego