I have Yii 2 gridview + pjax.
The issue I have is when I trigger pjax reload, it reloads the gridview and start at page 1 of the gridview.
I want the grid view page should stay the same. If I am on page 10, after pjax reload, the gridview should stay on page 10 , not starting from page 1.
<?php Pjax::begin(['id' => 'employee', 'timeout' => false, 'enablePushState' => false, 'clientOptions' => ['method' => 'POST']]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'id',
'label' => 'Employee',
'value' => function ($model) {
return $model->name;
}
],
],
]); ?>
<?php Pjax::end(); ?>
<script>
$.pjax.reload({container:'#employee'}); //refresh the grid
</script>