Difference between #1 and #2 of
Pjax GridView: refresh page after delete

Revision #2 has been created by hehbhehb on May 11, 2018, 3:56:41 AM with the memo:

update
« previous (#1) next (#3) »

Changes

Title changed

how does pjax of delete button in gridview work wellpjax gridview delete button issue

Category unchanged

How-tos

Yii version unchanged

2.0

Tags changed

ajax button in CGridView,pjax,pjax gridview delete refresh

Content changed

Normally, after clicking the delete button in gridview, the record will be deleted and the page will refresh, but the page number in query string is lost. This is not always what we wanthe case we expect. How to refresh current page with pjax after deleting the record? It seems there is no simple solutions, This is my way, it works well, although it is not clean     1. Controller file
 
 
```
 
public function actionDelete($id)
{
$this->findModel($id)->delete();
[...]
}
return $this->redirect(['index']);
}
 
```

 
 
2. index.php(view文件:) file)
 
 
 
```

<?php
$this->registerJs("
[...]
</div>
<?php Pjax::end(); ?>

 
```
 
 
 
6 0
4 followers
Viewed: 46 380 times
Version: 2.0
Category: How-tos
Written by: hehbhehb
Last updated by: CeBe
Created on: May 11, 2018
Last updated: 5 years ago
Update Article

Revisions

View all history