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'=>'mygrid',
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'id'=>'autoId',
'class'=>'CCheckBoxColumn',
'selectableRows' => '50',
),
array(
'name'=>'name',
'value'=>'$data->name',
),
array( // display 'status' using an expression
'name'=>'status',
'value'=>'$data->status',
),
array( // display a column with "view", "update" and "delete" buttons
'class'=>'CButtonColumn',
'template'=>'{edit} {status}',
'buttons' =>array
(
'edit' => array
(
'label'=>'Edit',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/edit.png',
'url'=>'Yii::app()->createUrl("product/prodcatedit", array("id"=>$data->id))',
),
'status' => array
(
'label'=>'status',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/edit.png', // make sure you have an image
'click'=>"function(){
$.fn.yiiGridView.update('mygrid', {
type:'POST',
url:$(this).attr('href'),
success:function(data) {
$('#AjFlash').html(data).fadeIn().animate({opacity: 1.0}, 3000).fadeOut('slow');
$.fn.yiiGridView.update('mygrid');
}
})
return false;
}",
'url'=>'Yii::app()->createUrl("product/categorystatus", array("id"=>$data->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