Cgridview Delete Action

Hi,

How can I change only the controller/action of delete icon in cgridview?

when I set


buttons'=>array(

'delete'=>array(

'url'=>'Yii::app()->createUrl("anotherController/action", array("id"=>$data->id))',

),

)

the javascript function that convert get method to post ,adds ajax variable and confirmation of delete not working

how achieve that with less code ?

Thanks

You can use CButtonColumn.deleteButtonUrl

http://www.yiiframework.com/doc/api/1.1/CButtonColumn#deleteButtonUrl-detail

Hi softark

could you give me an example?

Thanks

Not very different from your code:




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

    ...

    'columns' => array(

        ...

        array(

            'class' => 'CButtonColumn',

            'deleteButtonUrl' => 'Yii::app()->createUrl("anotherController/action", array("id"=>$data->id))',

        ),

    ),

));



Thanks a lot Softark!

It works perfectly! :)

A vote from me!

Thank’s you very very much softark,

You are really help me… :)

Hi

one thing if can call a ajax on delete button


 array(

                                'url'=>'Yii::app()->controller->createUrl("delete",array("id"=>$data->primaryKey))',

                             	'label'=>'delete',

                             	 'options'=>array(  // this is the 'html' array but we specify the 'ajax' element

                             		'confirm'=>$alert,

                                        'class'=>'grid_action_set1',

	                                 'ajax'=>array(

                                       'type'=>'POST',

                                       'url'=>"js:$(this).attr('href')", // ajax post will use 'url' specified above

	                                   'success'=>'function(data){

                                                if(data == "true"){

                                                                $.fn.yiiGridView.update("liquor-category-grid");

                                                                return false;

                                                }else{

                                                                window.location="admin?del=exist";

                                                                return false;

                                                }

                                            }',

	                                   

	                                 ),

                               ),

                            ),