Cgridview Cell Renderpartial A Form

Hello Yii lovers,

I face problem of rendering a form in a view.

At first my view should be displayed like this


before select.png

then, if user clicks one of the Name in the table, there will be generated a form like this


after select.png

There are 3 data in the table, but whatever I click, it still displays the same id…

For example, if I click the 137 Refreshing Guest Room, the right form displays detailed data of 137 Refreshing Guest Room.

It also only displays detailed data of 137 Refreshing Guest Room when I click the 1 Swimming Pool.

It is because this line

12 is the id of Refreshing Guest Room.

I wanna grab dynamic id from selected data, but it has no result.

If I change ‘model’=>$this->loadModel(12),


‘model’=>$this->loadModel($data->id),, it will result error => Undefined variable: data.

It’s sure because the above line is outside the cgridview widget.

As the cgridview successful to display, there is no problem in $dataprovider. I’ve already define $dataProvider in my controller. So what should I do to grab id of selected row?

These are full codes in my view

<?php Yii::app()->clientScript->registerScript('view', "



	return false;


$('.edit-form form').submit(function(){

	$.fn.yiiGridView.update('facility-grid', {

		data: $(this).serialize()


	return false;




<div class="row">

	<div class="small-6 columns">

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





					array('name'=>'id','header'=>'Name', 'type'=>'raw','value'=>'CHtml::link(CHtml::encode($data->quantity . " " . $data->name),array("#","id"=>$data->id),array("class"=>"edit-button"))'),







	<div class="small-6 columns">

		<div class="edit-form" style="display:none">

		<?php $this->renderPartial('_ajax_form_disable',array(


		)); ?>




Thanks for your attention ^^


u can check this

hope this help

Thanks Ankit for your reply

I’ve tried to move it, but it still results error -> Undefined variable: data

I wish it help

u can call a ajax on jquery



			var id =


				type: "GET",

				url: "<?php echo CController:<img src='' class='bbc_emoticon' alt=':(' />'test'); ?>";


				success: function(result) {






i wonder why the id still cannot be recognized :(