Pagination in gridview Yii2 without page reload
Asked Answered
S

3

5

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.

Swamy answered 27/11, 2014 at 7:34 Comment(3)
Use GridView widget. Don't reinvent the wheel. Pjax use simple - just before GridView you should run Pjax->begin and after GridView you should run Pjax->closeLibertine
Thank you @EvgeniyTkachenko ,and i used gridview between run pjax->begin and pjax->close but when click for next page for next data browser is reload.Swamy
done... i forgot to put pager in layout $layout = "{summary}\n{items}\n{pager}"Swamy
P
8

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

Pickled answered 2/2, 2015 at 17:28 Comment(0)
P
2

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(); ?>
Prototrophic answered 19/12, 2014 at 14:25 Comment(0)
B
1

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(); ?>
Bronson answered 6/1, 2016 at 6:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.