Ok, but how should the code of fancy function look like?
In afterDelete I have
'afterDelete' => 'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
but it doesn’t work in afterAjaxUpdate. Any ideas?
EDIT:
I’ve tried with this code:
'afterAjaxUpdate'=>'function(id, data){ $("#statusMsg").html(data); }',
and it’s also not working - loads to statusMsg div whole page…
Generaly my CGridView code in view admin.php looks now like:
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'users-grid',
//'ajaxUpdate' => false,
'dataProvider' => $model->search(),
'filter' => $model,
'afterAjaxUpdate'=>'function(id, data){ $("#statusMsg").html(data); }',
'columns' => array(
'login',
array(
'name' => 'rola',
'filter' => $this->getRoles(),
),
/* array(
'class' => 'CButtonColumn',
'header' => 'Akcja',
'afterDelete' => 'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
), */
array(
'class' => 'EButtonColumnWithClearFilters',
'header' => 'Akcja',
'afterDelete' => 'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
//'clearVisible'=>true,
//'onClick_BeforeClear'=>'alert('this js fragment executes before clear');',
//'onClick_AfterClear'=>'alert('this js fragment executes after clear');',
//'clearHtmlOptions'=>array('class'=>'custom-clear'),
//'imageUrl'=>'/path/to/custom/image/delete.png',
//'url'=>'Yii::app()->controller->createUrl(Yii::app()->controller->action->ID,array("clearFilters"=>1))',
'label' => 'Wyczyść wszystkie filtry',
),
),
));
and action delete in controller:
public function actionDelete($id) {
try {
$this->loadModel($id)->delete();
if (!isset($_GET['ajax']))
Yii::app()->user->setFlash('success', 'Item deleted.');
else
echo "<div class='flash-success'>Item deleted.</div>";
} catch (CDbException $e) {
if (!isset($_GET['ajax']))
Yii::app()->user->setFlash('error', 'Item cannot be deleted.');
else
echo "<div class='flash-error'>Item cannot be deleted.</div>";
}
if (!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
And of course div code:
<div id="statusMsg">
<?php if (Yii::app()->user->hasFlash('success')): ?>
<div class="flash-success">
<?php echo Yii::app()->user->getFlash('success'); ?>
</div>
<?php endif; ?>
<?php if (Yii::app()->user->hasFlash('error')): ?>
<div class="flash-error">
<?php echo Yii::app()->user->getFlash('error'); ?>
</div>
<?php endif; ?>
</div>
Thank you in advance for any help to solve my problem.