Gridview Dynamic Page Size


How can I implemented dynamic page size via a drop down using the GridView widget in Yii2? I want to have a dropdown next to each table that has the options of 10, 20, 50 and 100 results per page like it is done in jQuery datatables. Is there a native option for this?


Did you have a look at the doc?

You would have to pass the drop down value to the data provider configuration.

Yes, but I was looking for a native functionality - a native dropdown embedded in the GridView widget.

Now I have another question: How can I pass the dropdown parameter together with the filters of the grid?

Suppose I have this code in the view:

<?= Html::dropDownList('pagesize', 10,

            array(10 => 10, 20 => 20, 50 => 50, 100 => 100),

            array('id' => 'pagesize')

        ) ?>


    <?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],





            ['class' => 'yii\grid\ActionColumn'],


    ]); ?>

How can I pass the value of the "pagesize" select through _GET together with the filters from the grid (the searches)?

have you seen

click on personalize

That will do, Thanks.