CGridView and CButtonColumn not working correctly

hi

im having trouble with delete action with CButtonColumn inside a Grid

Problem is: when delete ajax is sent there are no way to know what id to remove


	<?php 

		$dataProvider=new CActiveDataProvider('User', array(

			'pagination'=>array(

        		'pageSize'=>50,

    		),

		));

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

			'dataProvider'=>$dataProvider,

			

			'columns'=>array(

				'id:text:ID',

				'status:text:Status',

				'username:text:Username',

				//'password:text:Password',

				'email:text:Email',

				'phone:text:Phone',

				'name:text:Name',

				'street:text:Street',

				'birthday:text:Birthday',

				'money:text:Money',

				'invested:text:Inv.',

				'investedtimes:text:IT.',

				'since:text:Since',

				array(

					'class'=>'CButtonColumn',

					'header'=>'Options',

					'template'=>'{update}{delete}',

					'updateButtonUrl'=>'Yii::app()->createUrl("admin/users/update/".$data->id)',

					'deleteButtonUrl'=>'Yii::app()->createUrl("admin/users/delete/".$data->id)',

				),

			),

		));

	?>



Scripts:


/*<![CDATA[*/

jQuery(function($) {

jQuery('#yw0 a.delete').live('click',function() {

	if(!confirm('Are you sure you want to delete this item?')) return false;

	$.fn.yiiGridView.update('yw0', {

		type:'POST',

		url:$(this).attr('href'),

		data:{ 'YII_CSRF_TOKEN':'905fa8c11bfdbc64933d91044bfc9e0c0a7cab62' },

		success:function() {

			$.fn.yiiGridView.update('yw0');

		}

	});

	return false;

});

jQuery('#yw0').yiiGridView({'ajaxUpdate':['yw0'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items','selectableRows':1,'pageVar':'User_page'});

jQuery('#dialog_AboutUs').dialog({'title':'Acerca','autoOpen':false,'modal':true,'width':'700','resizable':false});

jQuery('#dialog_OurGuarantee').dialog({'title':'Garantias','autoOpen':false,'modal':true,'maxWidth':600});

jQuery('#dialog_Privacy').dialog({'title':'Privacidade','autoOpen':false,'modal':true,'maxWidth':600});

});

/*]]>*/

</script> 

Action:


public function actionUsers()

	{

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

		{

			$fp = fopen('text.txt', 'w');

			fwrite($fp, print_r($_GET, true));

			fwrite($fp, sizeof($_REQUEST));

			foreach($_POST as $value => $key)

				fwrite($fp, $key);

			fclose($fp);

			return true;

		}

		else

			$this->render('users');

	}

output on txt:


Array

(

    [ajax] => yw0

)

1

how could i recive the post id to remove a user from list?

thanks

you try

add this code at: array(

                                    'class'=&gt;'CButtonColumn',


                                    'header'=&gt;'Options',


                                    'template'=&gt;'{update}{delete}',


                                    'updateButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;admin/users/update/&quot;.&#036;data-&gt;id)',


                                    'deleteButtonUrl'=&gt;'Yii::app()-&gt;createUrl(&quot;admin/users/delete/&quot;.&#036;data-&gt;id)',








                                    'urlExpression'=&gt;'&quot;index.php?r=responsabili/view&amp;id=&quot;.&#036;data-&gt;id_responsabili',


                            ),

this doesn’t work urlExpression is not a property of CButtonColumn

sorry

$data->id is giving errors.

without passing that id. i cant do update & delete operations.

how to get around with this?