pjax reload gridview should stay on same page

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>




Try checking:




$.pjax.reload({container: "#employee", url: "/controller/index"});



thanks alot. didnt know I can do that. This is my code. Hope it helps others




// get the current gridview page url

var url = $('#employee-pay-roll-assignment-id li.active a').attr('href');


// refresh the grid 

$.pjax.reload({container:'#employee-pay-roll-assignment-id', url: url});