Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pagination in gridview Yii2 without page reload

I am a Yii2 beginner. I have almost completed all of my grid-view except for pagination. I tried to use pjax but can't find a solution.

like image 982
Sohel Tambadiya Avatar asked Nov 27 '14 07:11

Sohel Tambadiya


Video Answer


3 Answers

You have to set timeout for Pjax (default is 1000 ms). Sometimes it is not enough and plugin will reload the page completely.

<?php \yii\widgets\Pjax::begin(['timeout' => 10000, 'clientOptions' => ['container' => 'pjax-container']]); ?>
<?= GridView::widget([
 // ... configuration here
]);?>
<?php \yii\widgets\Pjax::end(); ?>

see here

like image 105
Rostyslav Pylypenko Avatar answered Oct 17 '22 14:10

Rostyslav Pylypenko


Put your code between Pjax::begin and Pjax::end this work for every thing not only the gridview

<?php \yii\widgets\Pjax::begin(); ?>
<?= GridView::widget([
 // ... configuration here
]);?>
<?php \yii\widgets\Pjax::end(); ?>
like image 32
Devy Avatar answered Oct 17 '22 16:10

Devy


This May Help...:)

Just start and end Pjax thats all..

<?php 
    use yii\widgets\Pjax;
     <?php Pjax::begin(['id'=>'type_id']); //id is used for jquery opertaion  ?> 
    <?php echo GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],

                //'id',
                //'user_id',
                'type',

                ['class' => 'yii\grid\ActionColumn'],
            ],
        ]); ?>
    <?php Pjax::end(); ?>
like image 1
Kalpesh Desai Avatar answered Oct 17 '22 15:10

Kalpesh Desai