Flash Message

Hi guys,

I want to show flash message after ajax request on bootstrap.widgets.TbGridView delete link.When user wants to delete item, i then check if that record has some child records then I set flash message but that is not showing in view. following is my code:

CONTROLLER.PHP

public function actionDelete($id)

{


	if(Yii::app()->request->isPostRequest)


	{


	// Check if  product type is connected with other module


		$aCheckDeptEmp = array();


		$aCheckLink = Products::model()->findAll('ptype=:pt', array(':pt'=>$id));


		if(count($aCheckLink) > 0) {


			Yii::app()->user->setFlash('success','PRODUCT TYPE linked with product(s)');


			/*$this->render('admin',array(


				'model'=>ProductType::model(),


	));//*/


			//$this->actionAdmin();


			//return;


		} else {				$model=$this->loadModel($id);


			$model->edt = date("Y-m-d H:i:s");


			$model->save(false);


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


	}


	else


		throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');


}

VIEW.PHP

<?php if(Yii::app()->user->hasFlash(‘success’)):?>

&lt;div class=&quot;flash-error&quot;&gt;


    &lt;?php echo Yii::app()-&gt;user-&gt;getFlash('success'); ?&gt;


&lt;/div&gt;

<?php endif; ?>

You need to use ‘ajaxUpdate’ attribute of TbGridView.

‘ajaxUpdate’ calls a division of flash message after an ajax function call of TbGridView.

VIEW.PHP


<div id="flash-msgs"><?php 

        if(Yii::app()->user->hasFlash("success")) {        

                ?><div class="flash-error"><?php         

                        echo Yii::app()->user->getFlash("success"); 

                ?></div><?php

        }


        if(Yii::app()->user->hasFlash("error")) {        

                ?><div class="flash-success"><?php         

                        echo Yii::app()->user->getFlash("error"); 

                ?></div><?php

        }

?></div>


$this->widget('bootstrap.widgets.TbGridView', array(

        'type' => 'striped bordered',

        'id' => 'category-grid',

        'ajaxUpdate' => 'flash-msgs',

        'dataProvider' => $model->search(),

        'template' => "{items}",

        'filter' => $model,

        'columns' => array(

                ...

        ),

));

Let me know if any concern/concern regarding this.

Thanks,

Saurabh Dhariwal