Cgridview Delete Option

I everyone i have a cgridview and the data provider is from a diferent model so i have changed the button options , and all worked fine.One problem: When i press the delete option the row is eliminated but the cgridview desapear.

here my delete button




array

  (

	  'class'=>'CButtonColumn',

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

	  'buttons'=>array(

	  	  

		  'delete' => array

		  (

			  'url'=>'Yii::app()->createUrl("linha_notificacao/delete", array("id"=>$data->n_linha_notificacao))',

			  			   'options'=>array('title'=>'Apagar...')

		  ),

		  ),

		  ),

	),



here is the delete control function




public function actionDelete($id)

	{

		$this->loadModel($id)->delete();

		

		// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser

		if(!isset($_GET['ajax']))

			$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));

	}




what i should do on the controller function ? Maybe redirect back to the view ? Help please :)

Hi,

you can use this some thing look like this


$alert = 'Are you sure?'


array(

            'header' => 'Action',

            'class' => 'CButtonColumn',

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

            'buttons' => array('delete' =>

                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;

                                                }

                                            }',

                        ),

                    ),

                ),

                'update' => array(

                    'options' => array('class' => 'grid_action_set'),

                ),

            ),

            //'buttons'=>UtilityHtml::getGridButtonAjax1($formId, $gridId, $modelName),

            'htmlOptions' => array('width' => '8%')

        ),

[size=2]Hi thanks but i tryed and didnt work [/size]




 'delete'=> 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' => 'Tem a certeza?',

                        //'class' => 'grid_action_set1', dont need this right?

                        '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("#linha--contacto-grid");

                                                                return false;

                                                }else{

                                                                window.location="index.php";

                                                                return false;

                                                }

                                            }',

                        ),



i made a mistake ? thanks

Hi,

you missing the options and delete array brcket


'delete'=> 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' => 'Tem a certeza?',

                        //'class' => 'grid_action_set1', dont need this right?

                        '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("#linha--contacto-grid");

                                                                return false;

                                                }else{

                                                                window.location="index.php";

                                                                return false;

                                                }

                                            }',

                        ))),