好吧,这很令人沮丧。
我只想做的是在 CGridView 删除操作后重新加载页面。由于删除是通过Ajax执行的,因此我似乎无法重新加载页面。
我需要这样做,因为我在页面上有其他数据依赖于我要删除的数据。
我已经尝试过在视图中
'class'=>'CButtonColumn',
'header'=>'Delete',
'template'=>'{delete}',
'buttons'=>array(
'delete'=>array(
'success'=>'function(){
window.location = location.href;
}',
),
),
也在删除控制器中
echo CHtml::script("
window.location.reload();
");
Yii::app()->end();
任何帮助表示赞赏。
问候
您可以使用存在于类CButtonColumn
afterDelete参数(属性):
'class'=>'CButtonColumn',
'header'=>'Delete',
'template'=>'{delete}',
'afterDelete'=>'function(link,success,data){
if(success) { // if ajax call was successful !!!
if(data == SUCCESS_TEXT) { // SUCCESS_TEXT the text which you output in your delete action on success
window.location.reload();
} else {
alert("Error! not deleted.");
}
} else {
alert("Error! delete request failed, see console for mor info");
console.log(data);
}
}',