Yii 从cgridview删除后如何弹出消息框?

Yii 从cgridview删除后如何弹出消息框?,yii,Yii,这是我的gridview的CButtonColumn array( 'header' => 'Action', 'class' => 'CButtonColumn', 'template' => '{view} {delete}', 'buttons' => array( 'delete' =>

这是我的gridview的CButtonColumn

array(
            'header'    => 'Action',
            'class'     => 'CButtonColumn',
            'template'  => '{view} {delete}',
            'buttons'   => array(
                'delete'    =>
                array(
                    'url' => 'Yii::app()->controller->createUrl("/workorders/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"){
                                    //update the grid...
                                    $.fn.yiiGridView.update("workorders-grid");
                                    return false;
                                }else{

                                    $("#mydialog").dialog("open"); return false;
                                    return false;
                                }
                            }',
                        ),
                    ),
                ),
                'view' => array
                (
                        'label'=>'View workorder detail.',
                        'url'=>'Yii::app()->createUrl("/workorders/view", array("id"=>$data->id))',
                ),
            ),

            'htmlOptions' => array('width' => '30px', 'style'=>'text-align:center;')
        ),
这是删除前检查记录的步骤

protected function beforeDelete() 
    {
        if ($this->exists("(status_id = 6 OR status_id = 7) AND parent_mac = '$this->mac_address'"))
            return false;
        else
            return parent::beforeSave(); // prevent actual DELETE query from being run  
    }
这是我的控制器

public function actionDelete($id)
    {
            if($this->loadModel($id)->delete())
            {
                if(!isset($_GET['ajax']))
                    Yii::app()->user->setFlash('success','Normal - Deleted Successfully');
                else
                    echo "<div class='flash-success'>Ajax - Deleted Successfully</div>";

                $data = 'true';
            }else{
                if(!isset($_GET['ajax']))
                    Yii::app()->user->setFlash('error','This node is a parents of some other node. <br/>Please replace.');
                else
                    echo "<div class='flash-error'>This node is a parents of some other node. <br/>Please replace.</div>";

                $data = 'false';
            }

        // 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'));
    }
public函数actionDelete($id)
{
如果($this->loadModel($id)->delete())
{
如果(!isset($\u GET['ajax']))
Yii::app()->user->setFlash(“成功”,“正常-删除成功”);
其他的
echo“Ajax-已成功删除”;
$data='true';
}否则{
如果(!isset($\u GET['ajax']))
Yii::app()->user->setFlash('错误','此节点是其他某个节点的父节点。
请替换'); 其他的 echo“此节点是其他节点的父节点。
请替换。”; $data='false'; } //如果AJAX请求(通过管理网格视图删除触发),我们不应该重定向浏览器 如果(!isset($\u GET['ajax'])) $this->redirect(isset($\u POST['returnUrl'])?$\u POST['returnUrl']:数组('admin'); }
我的问题是当用户点击删除按钮时,确认框“你确定要删除吗?”会出现。当用户单击“是”时,检查记录是否有效以删除

如果记录可有效删除,则删除该记录并弹出“成功”消息框。更新gridview

如果记录不能有效删除,弹出“记录是废话废话”消息框

我该怎么办

public function actionDelete($id) {
    $jenis = Usaha::model()->findByAttributes(array('id_jenis' => $id));
    if($jenis==''){
    $this->loadModel($id)->delete();
    }
else {
    throw new CHttpException(400, "your message alert "); //try this , will show some alert  this i used when some data connected with another table in database
}

// 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'));

}