ajaxLink in CGridView


I wanted to have every returned row trigger an ajax request.

I managed to get this to work by using CListView but I prefer the look of CGridView. What seems to happen is that the URL’s created by ajaxLink when contained by CGridView don’t have an id. Any idea if this is possible to do. Here’s the code that nearly works. Am I using the wrong approach. I’m fairly new to Yii, but I must say how impressed I am with it. This code works when it’s a regular ajaxLink but as soon as I try and include it as a part of CGridView it fails. The URL when clicked works as normal and gives a 404 error. Thanks in advance

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


	"selectableRows" => 1,


	'columns' => array(



				          'type' => 'html',

					 'value' => 'CHtml::ajaxLink(



					      array( // ajaxOptions

						    "type" => "POST",

						    "beforeSend" => "function( request )


								  // Set up any pre-sending stuff like initializing progress indicators


						 "success" => "function( data )


								// handle return data

								alert( data );


    					"data" => array( "val1" => "1", "val2" => "2" )



						array( //htmlOptions

						"href" => Yii::app()->createUrl("graph/ajaxRequest" ),











For the question column use:

'type' => 'raw',

Thanks. That works.

in my case, it worked too.

It didn’t worked as well as expected. It only work on the items loaded in the first page of the pager. It seems that Jquery sripts are not activated for the others. When I update the page to display another one, Ajax is no more performed but when I return to the first one, it works again. I found some other treads in the forum relating similar problem, but I do not found any solution.

Here is my code.

Added a nice sliding effect on a my dialog when opening:




        array(// ajaxOptions

            "type" => "GET",

            "success" => "function(data)


                $(\"#ajaxDialog\").slideUp(\"fast\", function(){




            "data" => array("id" => $data->idDemande)



            "href" => Yii::app()->createUrl("demandesReserv/showDetails", array("id" => $data->idDemande)),

            "id" => "dem" . $data->idDemande,



Outside of the grid:

<div id="ajaxDialog"></div>

The contoller:

public function actionShowDetails() {

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

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

            'Demande' => $this->loadModel(),


    } else {

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

            'Demande' => $this->loadModel(),