[ask]delete button CbuttonColumn

hello …

I use [RIGHTS extension] …

I grant permissions only to be able to see

in cgriedview I use CButtonColumn …

When I delete using the delete button CbuttonColum, the page does not redirect[in local]

2038

cbutton.JPG

in the server error massage it out but in the pop-up massage[in server]

2039

error.JPG

because of what things like this happen?

When you perform delete operation in grid view it made an ajax request where form will not be submitted, that’s why you get popup error message instead redirection.but the message correctly says that you do not have permission to perform the action.You can use below options to handle this error nicely.

  1. catch the exception in delete action and throw proper error message.

in your actionDelete do below modifications.


try

{

	$model = $this->loadModel($id);

	$model->delete() ;

}

catch (Exception $e)

{	

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

	{

		throw new CHttpException(400, 'You do not have permission to perform this action');

	}							

}


// by evaluation $e you can track the correct exception associated with permission



  1. By adding below to grid view you can disable ajax submission then page will be redirected to error page as you expected.

'ajaxUpdate'=>false

I added the code below


'ajaxUpdate'=>false

and runs perfectly .

Thank you very much ;D