Click Event Not Working In Cgridview

Hello All,

Please help me to sort out the issue which i am facing.

I am using cGridView and want to apply ajax to change the status of each record(active/inactive)

In action button I want to give ajax link to update the status(0 OR 1)

Problem : Click event is not showing in HTML view of <a> tag.

Here is my code :

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

'id'=&gt;'mygrid',


'dataProvider'=&gt;&#036;dataProvider,





'columns'=&gt;array(


    array(


        'id'=&gt;'autoId',


        'class'=&gt;'CCheckBoxColumn',


        'selectableRows' =&gt; '50',   


    ),





	array(     


        'name'=&gt;'name',


        'value'=&gt;'&#036;data-&gt;name',


    ),


	


	array(       // display 'status' using an expression


        'name'=&gt;'status',


        'value'=&gt;'&#036;data-&gt;status',


    ),


	


    array(    // display a column with &quot;view&quot;, &quot;update&quot; and &quot;delete&quot; buttons


        'class'=&gt;'CButtonColumn',


		'template'=&gt;'{edit} {status}',


		


		'buttons' =&gt;array


		(


			'edit' =&gt; array


			(


				'label'=&gt;'Edit',


				'imageUrl'=&gt;Yii::app()-&gt;request-&gt;baseUrl.'/images/edit.png',


				'url'=&gt;'Yii::app()-&gt;createUrl(&quot;product/prodcatedit&quot;, array(&quot;id&quot;=&gt;&#036;data-&gt;id))',


			),


			


			'status' =&gt; array


			(


			 'label'=&gt;'status',


			 'imageUrl'=&gt;Yii::app()-&gt;request-&gt;baseUrl.'/images/edit.png', // make sure you have an image


			 


			 'click'=&gt;&quot;function(){


                                &#036;.fn.yiiGridView.update('mygrid', {


                                    type:'POST',


                                    url:&#036;(this).attr('href'),


                                    success:function(data) {


                                          &#036;('#AjFlash').html(data).fadeIn().animate({opacity: 1.0}, 3000).fadeOut('slow');





                                          &#036;.fn.yiiGridView.update('mygrid');


                                    }


                                })


                                return false;


                          }&quot;,


			 'url'=&gt;'Yii::app()-&gt;createUrl(&quot;product/categorystatus&quot;, array(&quot;id&quot;=&gt;&#036;data-&gt;id))',


			 


			)


			


			


		),


			


    ),


    


),

)); ?>

AND in view there is no click event :

<a class="status" href="/backend/product/categorystatus?id=1" title="status">

<img alt="status" src="/images/edit.png">

</a>

Please let me know in case of anything i am doing wrong.

Thanks,

Vishal

Please refer this URL

and check are you doing in correct way. also please use code block to put your code. So, easily it can understand. ;)

And also please check the function again which you have bind on click event. Is control is going into this or not.

Hi,

please see this link

www.yiiframework.com/forum/index.php/topic/42793-cgridview-delete-action/page__view__findpost__p__203223__fromsearch__1

it may be helpful