Difference between #4 and #5 of
Pjax GridView: refresh page after delete

Revision #5 has been created by CeBe on Jul 24, 2018, 2:11:51 PM with the memo:

updated markdown style
« previous (#4)

Changes

Title changed

pPjax gGridvView delete button issu: refresh page after delete

Category unchanged

How-tos

Yii version unchanged

2.0

Tags unchanged

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 the case we expect. How to refresh current page with pjax after deleting the record? It seems there is no very simple solution. 1. Controller file
 
 
   ```
public function actionDelete($id)
{
[...]
return $this->redirect(['index']);
}
```
 
 
 
``` 2. index.php (view file)
 
 
   ```    <?php
$this->registerJs("
$(document).on('ready pjax:success', function() {
[...]
});
");
   ?>    <?php Pjax::begin(['id' => 'my_pjax']); ?>
<div class="shop-index">
<?= GridView::widget([
[...]
]); ?>
</div>
   <?php Pjax::end(); ?>
 
   ```
 
6 0
4 followers
Viewed: 46 252 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